#upload-section #imagesUpload {
            position: absolute; width: 100%; height: 100%; top: 0; left: 0;
            opacity: 0; cursor: pointer; z-index: 10;
        }
        #upload-section #selectFileBtn { min-width: 240px; }
        .upload-area { position: relative; cursor: pointer; isolation: isolate;
            transition: background-color 0.3s ease, border-color 0.3s ease;
            border: 2px dashed #ced4da; border-radius: 12px;
            background: var(--light-bg, #f8f9fa); min-height: auto; }
        .upload-area:hover, .upload-area.dragover {
            background-color: #eef0f2; border-color: #6b7280 !important; }
        #dropArea, .upload-area.card {
            overflow: visible; max-width: 100%;
            --bs-card-bg: #f8f9fa;
            background-color: #f8f9fa !important; background: #f8f9fa !important;
            box-shadow: none !important; border: 2px dashed #ced4da !important; }
        .upload-pick-wrap { display: inline-flex; align-items: center; justify-content: center;
            gap: 12px; transform: none; position: relative; z-index: 20; }
        .upload-cloud-stack { display: flex; flex-direction: column; gap: 1px;
            position: relative; z-index: 220; pointer-events: auto; }
        .cloud-upload-btn { width: 45px; height: 45px; border-radius: 50%; display: flex;
            align-items: center; justify-content: center; border: 2px solid #dee2e6;
            background: white; transition: all 0.3s; cursor: pointer; padding: 0; z-index: 100; }
        .cloud-upload-btn:hover { border-color: #000; transform: scale(1.1); box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
        .cloud-icon { position: relative; display: inline-block; z-index: 101; }
        .cloud-tooltip { visibility: hidden; width: 140px; background-color: #333; color: #fff;
            text-align: center; border-radius: 6px; padding: 8px 5px; position: absolute;
            z-index: 1000; bottom: 125%; left: 50%; margin-left: -70px; opacity: 0;
            transition: opacity 0.3s; font-size: 12px; white-space: nowrap; pointer-events: none; }
        .cloud-tooltip::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px;
            border-width: 5px; border-style: solid; border-color: #333 transparent transparent transparent; }
        .cloud-icon:hover .cloud-tooltip { visibility: visible; opacity: 1; }
        #adContainer { margin: 20px 0; text-align: center; overflow: hidden; max-width: 100%; }
        #adContainer ins.adsbygoogle { display: block !important; width: min(100%, 728px) !important;
            max-width: 100% !important; margin-left: auto !important; margin-right: auto !important; }
        #upload-section #dropArea.upload-area,
        #upload-section #dropArea.card.upload-area,
        #upload-section #dropArea.card.shadow-sm.upload-area {
            width: min(100%, var(--itqan-tool-panel-w, 46.5rem));
            max-width: min(100%, var(--itqan-tool-panel-w, 46.5rem));
            margin-left: auto; margin-right: auto;
            padding: 0.65rem 1.55rem 0.45rem !important;
            box-shadow: none !important; overflow: visible !important;
            --bs-card-bg: #f8f9fa;
            background-color: #f8f9fa !important; background: #f8f9fa !important;
            border: 2px dashed #ced4da !important; }
        @media (min-width: 576px) {
            #upload-section #dropArea.upload-area,
            #upload-section #dropArea .card-body,
            #upload-section #dropArea .upload-row-wrap,
            #upload-section #dropArea .d-flex.justify-content-center {
                overflow: visible !important; }
        }
        @media (min-width: 992px) {
            #upload-section #dropArea.upload-area {
                padding-block: 0.75rem 0.5rem !important;
                padding-inline: 1.55rem !important;
                overflow: visible !important; }
        }
        @media (max-width: 575.98px) {
            #upload-section #dropArea.upload-area {
                width: 100%; padding: 1rem !important; overflow: visible !important; }
            #upload-section #dropArea .card-body,
            #upload-section #dropArea .upload-row-wrap {
                overflow: visible !important; }
        }
        #upload-section #dropArea .card-body {
            padding: 0.3rem 0.85rem 0.2rem; overflow: visible !important;
            width: 100%; background: transparent !important; }
        #upload-section #dropArea .upload-row-wrap {
            overflow: visible !important; width: 100%;
            display: flex; justify-content: center; align-items: center; }
        .container.my-5 { margin-top: 1rem !important; margin-bottom: 2rem !important; }
        #mergePageHeader {
            margin-bottom: 0 !important;
        }

        #mergePageHeader .display-5 {
            font-size: clamp(1.75rem, 3.5vw, 2.15rem);
            margin-bottom: 0.55rem !important;
            line-height: 1.25;
        }

        #mergePageHeader .lead {
            margin-bottom: 1.15rem !important;
            font-size: 0.98rem;
            line-height: 1.45;
        }
:root {
            --primary-color: #000000;
            --secondary-color: #333333;
            --light-bg: #f8f9fa;
            --border-color: #dee2e6;
            --accent-color: #0066cc;
            --sidebar-width: 340px;
            --viewer-surface: #ebebeb;
            --imgwm-viewer-pad: 140px;
            --imgwm-preview-scale: 0.6;
        }
        body,
        body.bg-light-subtle {
            background-color: var(--light-bg) !important;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        #dropArea,
        .upload-area.card {
            overflow: visible;
            max-width: 100%;
            --bs-card-bg: #f8f9fa;
            background-color: #f8f9fa !important;
            background: #f8f9fa !important;
            box-shadow: none !important;
            border: 2px dashed #ced4da !important;
        }
        .upload-area:hover,
        .upload-area.dragover {
            background-color: #eef0f2 !important;
            border-color: #6b7280 !important;
        }
        /* moved */ #imagesUpload-old { position: absolute; width: 100%; height: 100%; top:0; left:0; opacity:0; cursor:pointer; z-index:10; }
        .cloud-upload-btn {
            width:45px; height:45px; border-radius:50%; display:flex; align-items:center; justify-content:center;
            border:2px solid #dee2e6; background:white; transition:0.3s; cursor:pointer;
        }
        .cloud-upload-btn:hover { border-color:#000; transform:scale(1.1); box-shadow:0 2px 8px rgba(0,0,0,0.15); }
        .cloud-icon { position:relative; display:inline-block; }
        .cloud-tooltip {
            visibility:hidden; width:140px; background:#333; color:#fff; text-align:center; border-radius:6px;
            padding:8px 5px; position:absolute; z-index:1000; bottom:125%; left:50%; margin-left:-70px;
            opacity:0; transition:opacity 0.3s; font-size:12px; pointer-events:none;
        }
        .cloud-tooltip::after {
            content:""; position:absolute; top:100%; left:50%; margin-left:-5px;
            border-width:5px; border-style:solid; border-color:#333 transparent transparent transparent;
        }
        .cloud-icon:hover .cloud-tooltip { visibility:visible; opacity:1; }
        .btn-convert {
            background-color: #000000 !important;
            border-color: #000000 !important;
            color: #ffffff !important;
        }
        .btn-convert:hover {
            background-color: #333333 !important;
            border-color: #333333 !important;
        }
        .btn-outline-dark i.fa-trash {
            color: #dc3545 !important;
        }
        .btn-outline-dark:hover {
            border-color: #dc3545 !important;
        }
        .preview-container {
            border:1px solid #dee2e6; border-radius:8px; background:#f8f9fa; padding:15px;
            max-height:200px; overflow-y:auto;
        }
        .images-grid {
            display:grid; grid-template-columns:repeat(auto-fill, minmax(80px,1fr)); gap:10px;
        }
        .image-wrapper {
            position:relative; display:flex; flex-direction:column; gap:3px; padding:5px;
            border-radius:6px; background:white; border:2px solid transparent; cursor:pointer;
        }
        .image-wrapper:hover { border-color:var(--primary-color); background:#f8f9fa; }
        .image-wrapper.selected { border-color:var(--primary-color); background:#e9ecef; }
        .image-thumb {
            background:white; border:1px solid #dee2e6; border-radius:4px; display:flex;
            align-items:center; justify-content:center; overflow:hidden; width:100%; aspect-ratio:1/1;
        }
        .image-thumb img { max-width:100%; max-height:100%; object-fit:cover; }
        .action-btn {
            width:24px; height:24px; border-radius:50%; border:1px solid #dee2e6; background:white;
            cursor:pointer; display:flex; align-items:center; justify-content:center; transition:0.3s;
            position:absolute; top:2px; left:2px; z-index:5; font-size:12px;
        }
        .action-btn.delete { color:#dc3545; }
        .action-btn.delete:hover { background:#dc3545; color:white; border-color:#dc3545; }

        html {
            margin: 0; padding: 0; min-height: 100%; background-color: var(--light-bg);
            max-width: 100%; width: 100%;
        }
        html:not(.itqan-editor-active) { overflow-x: visible; }
        html:not(.itqan-editor-active) body.bg-light-subtle { overflow-x: visible; overflow-y: auto; }
        html.itqan-editor-active { height: 100%; overflow: hidden; }
        html.itqan-editor-active body.bg-light-subtle {
            overflow: hidden !important; height: 100%; max-height: 100dvh;
        }
        html.itqan-editor-active nav.navbar.navbar-expand-xl.navbar-dark.bg-dark {
            position: sticky; top: 0; z-index: 1040;
        }
        html.itqan-editor-active .navbar .dropdown-menu { z-index: 1060 !important; }
        @media (min-width: 1200px) {
            html.itqan-editor-active .navbar.navbar-expand-xl #navbarNav.collapse.navbar-collapse {
                max-height: none !important; overflow: visible !important;
            }
        }

        .main-editor {
            display: none; height: calc(100vh - 60px); flex-direction: row;
            min-width: 0; min-height: 0;
        }
        html.itqan-editor-active #imgwmEditorSection.main-editor {
            display: flex !important; position: fixed; left: 0; right: 0; bottom: 0;
            top: var(--itqan-editor-top, 72px); height: auto !important;
            min-height: 0 !important; box-sizing: border-box; z-index: 1;
        }
        #imgwmEditorSection .sidebar {
            width: var(--sidebar-width); min-width: var(--sidebar-width);
            flex: 0 0 var(--sidebar-width); background: #fff; border-left: 1px solid #ddd;
            display: flex; flex-direction: column; position: relative; z-index: 1;
            overflow: hidden; min-height: 0; height: 100%;
        }
        #imgwmEditorSection .sidebar .merge-sidebar-body {
            flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; padding-top: 0;
        }
        .merge-sidebar-header {
            flex-shrink: 0; padding: 16px 18px; border-bottom: 1px solid #eee;
            font-weight: 700; font-size: 17px; background: #fff; text-align: center; color: #222;
        }
        .merge-sidebar-body {
            padding: 16px 18px 12px; display: flex; flex-direction: column; gap: 14px;
        }
        #imgwmEditorSection .sidebar > .merge-sidebar-footer {
            flex-shrink: 0; margin-top: auto; padding: 14px 18px 18px;
            border-top: 1px solid #eee; background: #fff;
        }
        .merge-sidebar-section {
            display: flex; flex-direction: column; align-items: center; gap: 10px;
        }
        .merge-sidebar-label {
            font-size: 0.8rem; font-weight: 700; color: #666; text-align: center; margin: 0;
        }
        #imgwmEditorSection .merge-cloud-stack {
            display: flex; flex-direction: row; gap: 12px; align-items: center;
            justify-content: center; padding: 12px 14px; background: #f8f9fa;
            border: 1px dashed #dee2e6; border-radius: 10px; width: 100%; box-sizing: border-box;
        }
        .merge-sidebar-help-btn {
            width: 100%; margin: 0; padding: 0.55rem 0.75rem; font-size: 0.82rem; font-weight: 600;
            border: 1px dashed var(--border-color); border-radius: 8px; background: #fff; color: #333;
            display: flex; align-items: center; justify-content: center; gap: 0.45rem;
        }
        .merge-sidebar-help-btn:hover { background: #f8f9fa; border-color: #adb5bd; color: #111; }
        .merge-stats-sidebar.stats-card {
            display: flex; flex-direction: column; gap: 0; margin: 0; width: 100%;
            background: transparent; border: none; padding: 0;
        }
        .merge-stats-sidebar .merge-stat-item {
            display: flex; align-items: center; gap: 10px; padding: 10px 0;
            border-bottom: 1px solid #f0f0f0;
        }
        .merge-stats-sidebar .merge-stat-item:last-child { border-bottom: 0; }
        .merge-stats-sidebar .merge-stat-icon {
            width: 34px; height: 34px; border-radius: 50%; background: #111; color: #fff;
            display: inline-flex; align-items: center; justify-content: center;
            font-size: 13px; flex-shrink: 0;
        }
        .merge-stats-sidebar .merge-stat-text strong {
            display: block; font-size: 0.95rem; line-height: 1.15;
        }
        .merge-stats-sidebar .merge-stat-text small { font-size: 0.72rem; color: #888; }
        .merge-sidebar-btn-clear {
            width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid #ddd;
            background: #f5f5f5; color: #444; font-weight: 600; font-size: 0.9rem; cursor: pointer;
        }
        .merge-sidebar-btn-clear:hover { background: #eee; border-color: #bbb; color: #222; }
        .btn-finish {
            background: #000; color: #fff; width: 100%; border: none; padding: 15px;
            font-size: 18px; font-weight: 700; border-radius: 8px; cursor: pointer;
            transition: background 0.2s;
        }
        .btn-finish:hover:not(:disabled) { background: #222; color: #fff; }
        .btn-finish:disabled { opacity: 0.55; cursor: not-allowed; }

        .viewer-container {
            flex: 1 1 auto; min-width: 0; min-height: 0; background: var(--viewer-surface);
            overflow: hidden; padding: 0 12px 12px; height: 100%;
            display: flex; flex-direction: column;
        }
        #imgwmPreviewWrap {
            flex: 1 1 auto; min-height: 0; overflow: hidden; padding-top: 8px;
            display: flex; flex-direction: column;
        }
        html.itqan-editor-active #imgwmPreviewWrap {
            overflow: hidden;
        }
        html.itqan-editor-active #imgwmEditorSection .viewer-container {
            overflow: visible;
        }
        .audio-preview-card {
            border: none; border-radius: 12px; background: transparent;
            box-shadow: none; padding: 10px 12px 8px; margin-bottom: 8px;
            flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
        }
        html.itqan-editor-active .audio-preview-card > h6 {
            font-size: 0.82rem; margin-bottom: 8px; color: #666;
        }
        .viewer-container #imgwmAdContainerViewer {
            margin-top: 16px; flex-shrink: 0; text-align: center;
        }
        .viewer-container #imgwmAdContainerViewer ins.adsbygoogle {
            display: inline-block !important;
            width: min(100%, 728px) !important;
            max-width: 100% !important;
        }

        .imgwm-tab-row.toolbar-simple {
            display: flex; justify-content: center; gap: 10px; margin: 0; width: 100%;
        }
        .imgwm-tab-row.toolbar-simple button {
            flex: 1 1 0; padding: 10px 12px; border-radius: 40px; font-weight: 600;
            border: none; background: white; box-shadow: 0 2px 10px rgba(0,0,0,0.05);
            transition: 0.2s; font-size: 0.9rem;
        }
        .imgwm-tab-row.toolbar-simple button.active {
            background: var(--accent-color); color: white;
        }
        .imgwm-tab-row.toolbar-simple button i { margin-inline-end: 6px; }

        #imgwmEditorSection .viewer-container {
            display: flex;
            flex-direction: column;
            padding: 0 12px 12px;
            overflow: visible;
        }
        .files-bar {
            flex-shrink: 0;
            padding: 8px 0 12px;
            background: transparent;
            border-bottom: none;
        }
        .files-bar__inner {
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            align-items: center;
            justify-content: center;
            gap: 6px 10px;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
        }
        .files-bar .file-pill {
            display: inline-flex;
            align-items: center;
            gap: 10px;
            background: #ffffff;
            border: 1px solid #e0e0e0;
            border-radius: 999px;
            padding: 6px 14px 6px 10px;
            box-shadow: 0 1px 4px rgba(0,0,0,0.06);
            min-width: min(100%, 320px);
            max-width: min(100%, 520px);
        }
        .files-bar .file-pill__select {
            flex: 1;
            border: none;
            background: transparent;
            font-size: 14px;
            outline: none;
            text-align: right;
            direction: rtl;
            min-width: 0;
            max-width: 100%;
            cursor: pointer;
            appearance: none;
            -webkit-appearance: none;
            -moz-appearance: none;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            padding-inline-end: 4px;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: left 4px center;
            padding-left: 18px;
        }
        html[dir="ltr"] .files-bar .file-pill__select {
            text-align: left;
            direction: ltr;
            background-position: right 4px center;
            padding-left: 4px;
            padding-right: 18px;
        }
        .files-bar .file-pill__select option {
            direction: rtl;
            text-align: right;
        }
        .files-bar .file-pill__delete {
            background: transparent;
            border: none;
            color: #6c757d;
            font-size: 16px;
            cursor: pointer;
            padding: 4px 6px;
            border-radius: 6px;
            transition: color 0.2s, background 0.2s;
        }
        .files-bar .file-pill__delete:hover {
            color: #dc3545;
            background: #f8d7da33;
        }

        .editor__toolbar {
            display: flex; background: #fff; border-radius: 40px; padding: 5px 15px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05); flex-wrap: wrap;
            justify-content: center; align-items: center; gap: 10px;
        }
        .imgwm-editor-tools { margin-bottom: 8px; flex-shrink: 0; min-height: 0; }
        .imgwm-editor-tools .editor__toolbar {
            width: 100%; max-width: 100%; margin-bottom: 8px;
        }
        .imgwm-toolbar-top {
            padding: 20px 0 4px;
            margin-bottom: 0;
            overflow: visible;
        }
        .imgwm-editor-tools {
            overflow: visible;
        }
        .audio-preview-card .files-bar {
            padding: 0 0 12px;
        }
        .files-bar--in-toolbar {
            padding: 0;
            margin: 0;
            flex: 1 1 auto;
            min-width: min(220px, 40vw);
            max-width: min(420px, 55vw);
        }
        #filesToolbar .files-bar--in-toolbar {
            max-width: min(520px, 90vw);
            flex: 0 1 auto;
            min-width: 0;
            width: auto;
            margin-inline: auto;
        }
        #filesToolbar .files-bar--in-toolbar .files-bar__inner {
            width: auto;
            justify-content: center;
        }
        #filesToolbar .files-bar--in-toolbar .file-pill {
            width: auto;
            min-width: min(280px, 70vw);
            max-width: min(520px, 90vw);
        }
        #filesToolbar .editor__toolbar__options {
            width: 100%;
            justify-content: center;
        }
        #filesToolbar .imgwm-files-slot {
            flex: 0 1 auto;
            justify-content: center;
            width: auto;
            max-width: 100%;
        }
        #filesToolbar {
            justify-content: center;
        }
        .files-bar--in-toolbar .files-bar__inner {
            justify-content: stretch;
            width: 100%;
        }
        .files-bar--in-toolbar .file-pill {
            width: 100%;
            min-width: 0;
            max-width: none;
            background: #f5f5f5;
            box-shadow: none;
            padding: 4px 12px;
        }
        .imgwm-files-slot {
            display: flex;
            align-items: center;
            flex: 1 1 auto;
            min-width: 0;
        }
        .editor__toolbar__block.toolbar-zoom {
            gap: 2px;
            padding: 2px 6px;
        }
        .toolbar-zoom .imgwm-zoom-btn {
            width: 28px; height: 28px; border: none; border-radius: 50%;
            background: transparent; color: #222; font-size: 1.05rem; line-height: 1;
            cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
            transition: background 0.15s;
        }
        .toolbar-zoom .imgwm-zoom-btn:hover { background: #e0e0e0; }
        .toolbar-zoom .imgwm-zoom-btn:disabled { opacity: 0.45; cursor: not-allowed; }
        .toolbar-zoom .imgwm-zoom-pct {
            min-width: 38px; text-align: center; font-size: 0.8rem;
            font-weight: 600; color: #333; padding: 0 2px;
        }
        .imgwm-preview-large {
            width: 100%; flex: 1 1 auto; min-height: 0;
            overflow-y: auto; overflow-x: hidden;
            display: flex; justify-content: center; align-items: flex-start;
            scroll-behavior: smooth;
        }
        .imgwm-preview-stage {
            width: 100%; flex: 0 0 auto;
            display: flex; justify-content: center; align-items: flex-start;
            background: transparent; border-radius: 0;
            overflow: visible; padding: 25px; box-sizing: border-box;
        }
        html.itqan-editor-active .imgwm-preview-stage {
            min-height: 0;
        }
        .imgwm-thumbs.preview-container {
            max-width: 100%; width: 100%; margin-top: 8px; max-height: 118px;
            flex-shrink: 0;
        }

        @media (max-width: 991.98px) {
            html.itqan-editor-active { overflow: auto !important; height: auto !important; }
            html.itqan-editor-active body { overflow: auto !important; height: auto !important; max-height: none !important; }
            .main-editor { flex-direction: column !important; height: auto !important; }
            html.itqan-editor-active .main-editor { position: relative !important; flex-direction: column !important; height: auto !important; top: auto !important; left: auto !important; right: auto !important; bottom: auto !important; }
            .sidebar { order: 1 !important; position: relative !important; width: 100% !important; min-width: 0 !important; max-height: none !important; height: auto !important; flex: none !important; border-left: none; border-top: 1px solid #ddd; }
            .sidebar .merge-sidebar-body { overflow: visible !important; max-height: none !important; height: auto !important; }
            .viewer-container { order: 2 !important; width: 100% !important; min-height: 50vh; overflow: visible !important; }
            .sidebar > .merge-sidebar-footer, .main-editor .p-3 { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1050; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)) !important; background: #fff; border-top: 1px solid #e8e8e8; box-shadow: 0 -4px 20px rgba(0,0,0,0.1); }
            .btn-finish { padding: 14px !important; font-size: 16px !important; border-radius: 10px !important; }
            html.itqan-editor-active .tool-seo-visible-wrap, html.itqan-editor-active .merge-seo-content { display: none !important; }

            /* Mobile: 2-row toolbar */
            #textToolbar.editor__toolbar,
            #imageToolbar.editor__toolbar {
                overflow: visible;
                max-height: none;
                padding-top: 10px;
                padding-bottom: 10px;
            }
            #textToolbar .editor__toolbar__options,
            #imageToolbar .editor__toolbar__options {
                overflow: visible;
                flex-direction: column;
                flex-wrap: nowrap;
                align-items: center;
                justify-content: center;
                gap: 8px;
                width: 100%;
            }
            #textToolbar .imgwm-toolbar-row,
            #imageToolbar .imgwm-toolbar-row {
                display: flex;
                flex-wrap: nowrap;
                align-items: center;
                justify-content: center;
                gap: 6px;
                width: 100%;
                min-width: 0;
            }
            #textToolbar .imgwm-toolbar-row--controls,
            #imageToolbar .imgwm-toolbar-row--controls {
                flex-wrap: wrap;
                row-gap: 6px;
                column-gap: 4px;
            }
            #textToolbar .imgwm-toolbar-row--controls .editor__toolbar__block,
            #imageToolbar .imgwm-toolbar-row--controls .editor__toolbar__block {
                margin: 0;
            }
            #textToolbar .imgwm-files-bar,
            #imageToolbar .imgwm-files-bar {
                max-width: min(46vw, 200px);
            }
            /* Center option panels so they aren't clipped at screen edges */
            #textToolbar .editor__option__content,
            #imageToolbar .editor__option__content {
                position: fixed !important;
                left: 50% !important;
                top: 50% !important;
                right: auto !important;
                bottom: auto !important;
                transform: translate(-50%, -50%) !important;
                width: min(92vw, 340px) !important;
                max-width: 92vw !important;
                max-height: 70vh !important;
                overflow-y: auto !important;
                z-index: 3000 !important;
                box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22) !important;
            }
            .toolbar-color .editor__option__content .row,
            .toolbar-background .editor__option__content .row {
                width: 100% !important;
                flex-direction: column !important;
                gap: 12px !important;
                margin: 0 !important;
            }
            .toolbar-color .editor__option__content .col,
            .toolbar-background .editor__option__content .col {
                width: 100% !important;
                max-width: 100% !important;
            }
            body.imgwm-popover-open::before {
                content: '';
                position: fixed;
                inset: 0;
                background: rgba(15, 23, 42, 0.28);
                z-index: 2990;
                pointer-events: none;
            }
        }
        @media (min-width: 992px) {
            #textToolbar .imgwm-toolbar-row,
            #imageToolbar .imgwm-toolbar-row {
                display: contents;
            }
        }

        /* معاينة العلامة المائية — نفس أسلوب صفحة PDF في crop_pdf.php */

        .image-container {
            position: relative;
            display: inline-block;
            flex-shrink: 0;
            background: #fff;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.45);
            border-radius: 0;
            overflow: visible;
            line-height: 0;
        }
        .image-container #previewImage {
            border-radius: 0;
        }
        #previewImage {
            display: block;
            width: auto;
            height: auto;
            border-radius: 0;
            vertical-align: top;
        }
        .watermark-wrapper {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
        }
        #watermarkDiv {
            position: absolute;
            left: 0;
            top: 0;
            cursor: move;
            user-select: none;
            -webkit-user-select: none;
            pointer-events: auto;
            transform-origin: center center;
            will-change: transform;
            border: 1px dashed rgba(255,255,255,0.8);
            background: transparent;
            max-width: 100%;
            max-height: 100%;
            touch-action: none;
        }
        /* الجوال: امنع تمرير الصفحة أثناء سحب العلامة أو مقابضها */
        #watermarkDiv .watermark-content,
        #watermarkDiv .resize-handle,
        #watermarkDiv .rotate-handle {
            touch-action: none;
        }
        #watermarkDiv.wm-editing-text,
        #watermarkDiv.wm-editing-text .watermark-content {
            touch-action: auto;
        }
        #watermarkDiv.dragging,
        #watermarkDiv.wm-text-mode:not(.wm-editing-text) {
            cursor: move;
        }
        .watermark-content {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: inherit;
            color: inherit;
            font-family: inherit;
            font-size: inherit;
            padding: 0;
            box-sizing: border-box;
        }
        #watermarkDiv.wm-text-mode .watermark-content {
            padding: 5px 8px;
            cursor: move;
            outline: none;
            min-width: 1ch;
            white-space: nowrap;
            -webkit-user-select: none;
            user-select: none;
            caret-color: transparent;
        }
        #watermarkDiv.wm-text-mode.wm-editing-text {
            cursor: text;
            border-color: #3b82f6;
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
        }
        #watermarkDiv.wm-text-mode.wm-editing-text .watermark-content {
            cursor: text;
            caret-color: currentColor;
            -webkit-user-select: text;
            user-select: text;
        }
        #watermarkDiv.wm-text-mode .watermark-content:empty::before {
            content: attr(data-placeholder);
            opacity: 0.55;
            pointer-events: none;
        }
        .resize-handle {
            position: absolute;
            width: 10px;
            height: 10px;
            background: white;
            border: 1px solid black;
            border-radius: 50%;
            z-index: 10;
        }
        .handle-nw { top: -5px; left: -5px; cursor: nw-resize; }
        .handle-ne { top: -5px; right: -5px; cursor: ne-resize; }
        .handle-sw { bottom: -5px; left: -5px; cursor: sw-resize; }
        .handle-se { bottom: -5px; right: -5px; cursor: se-resize; }
        .rotate-handle {
            position: absolute;
            top: -52px;
            left: 50%;
            transform: translateX(-50%);
            width: 36px;
            height: 34px;
            background: #2b2f36;
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 8px;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
            cursor: grab;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 30;
            touch-action: none;
            -webkit-user-select: none;
            user-select: none;
            color: #fff;
        }
        .rotate-handle:active { cursor: grabbing; }
        .rotate-handle i {
            font-size: 14px;
            color: #fff;
            pointer-events: none;
        }
        #watermarkDiv .rotate-handle {
            touch-action: none;
        }


        .editor__toolbar__options {
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
        }
        .editor__toolbar__block {
            display: flex;
            align-items: center;
            gap: 5px;
            background: #f5f5f5;
            border-radius: 30px;
            padding: 2px 5px;
        }
        .editor__toolbar__option {
            position: relative;
            cursor: pointer;
            padding: 5px 8px;
            border-radius: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.2s;
        }
        .editor__toolbar__option:hover {
            background: #e0e0e0;
        }
        #toFrontBtn.active,
        #imageToFrontBtn.active {
            background: #d0d0d0;
        }
        .editor__toolbar__option[title] {
            position: relative;
        }
        .editor__toolbar__option[title]:hover::after {
            content: attr(title);
            position: absolute;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%);
            background: #333;
            color: #fff;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 12px;
            white-space: nowrap;
            z-index: 2000;
            pointer-events: none;
            margin-bottom: 5px;
        }
        .editor__option__selector {
            display: flex;
            align-items: center;
            gap: 5px;
        }
        .font-selected {
            font-size: 14px;
            white-space: nowrap;
        }
        .editor__option__content {
            position: absolute;
            top: 100%;
            left: 0;
            background: white;
            border: 1px solid #ddd;
            border-radius: 8px;
            padding: 10px;
            z-index: 1000;
            min-width: 200px;
            max-height: 300px;
            overflow-y: auto;
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        }
        .font-selector {
            padding: 5px;
            cursor: pointer;
            border-radius: 4px;
        }
        .font-selector:hover {
            background: #f0f0f0;
        }
        .font-selector.active {
            background: var(--accent-color);
            color: white;
        }
        .font-selector.disabled {
            color: #aaa;
            cursor: not-allowed;
        }
        .form__group--inline-3 {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .form__group--inline-3 input[type=range] {
            width: 120px;
        }
        .rangeInput {
            width: 60px;
        }
        .toolbar-align .row {
            display: flex;
            gap: 5px;
        }
        .textAlign {
            padding: 5px;
            border-radius: 4px;
        }
        .textAlign.active {
            background: var(--accent-color);
        }
        .textAlign.active svg g {
            fill: white;
        }
        .toolbar-background .editor__option__content .row {
            width: 250px;
        }
        .toolbar-color .editor__option__content .row {
            width: 400px;
            display: flex;
            gap: 20px;
        }

        /* حقل إدخال النص في الشريط */
        .text-input-wrapper {
            background: #f5f5f5;
            border-radius: 30px;
            padding: 2px 10px;
            display: flex;
            align-items: center;
        }
        .text-input-wrapper input {
            border: none;
            background: transparent;
            outline: none;
            width: min(220px, 28vw);
            padding: 5px;
        }
        .imgwm-editor-tools .text-input-wrapper input {
            width: min(280px, 42vw);
        }
        /* زر رفع الصورة — نص مترجم بدل واجهة المتصفح (اختيار ملف / لم يتم اختيار ملف) */
        .image-upload-wrapper {
            background: #f5f5f5;
            border-radius: 30px;
            padding: 4px 10px;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            max-width: min(320px, 52vw);
            min-width: 0;
        }
        .image-upload-wrapper .imgwm-wm-file-input {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border: 0;
        }
        .image-upload-wrapper .imgwm-wm-file-btn {
            flex: 0 0 auto;
            margin: 0;
            padding: 4px 10px;
            border-radius: 20px;
            border: 1px solid #ccc;
            background: #fff;
            color: #222;
            font-size: 12px;
            font-weight: 600;
            line-height: 1.2;
            cursor: pointer;
            white-space: nowrap;
        }
        .image-upload-wrapper .imgwm-wm-file-btn:hover {
            border-color: #999;
            background: #fafafa;
        }
        .image-upload-wrapper .imgwm-wm-file-name {
            flex: 1 1 auto;
            min-width: 0;
            font-size: 12px;
            color: #666;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        html[lang="en"] .imgwm-latin-digits,
        html[lang="en"] #fontSizeNumber,
        html[lang="en"] #opacityNumber,
        html[lang="en"] #imageOpacityNumber {
            font-family: Arial, "Segoe UI", Tahoma, sans-serif !important;
            font-feature-settings: "locl" 0;
            -webkit-locale: "en";
            direction: ltr;
            unicode-bidi: isolate;
        }

        /* مربع الرفع — نهائي: مطابق merge_pdf / image_compressor */
        #upload-section #dropArea.upload-area,
        #upload-section #dropArea.card.upload-area,
        #upload-section #dropArea.card.shadow-sm.upload-area {
            width: min(100%, var(--itqan-tool-panel-w, 46.5rem));
            max-width: min(100%, var(--itqan-tool-panel-w, 46.5rem));
            margin-left: auto;
            margin-right: auto;
            padding: 0.65rem 1.55rem 0.45rem !important;
            box-shadow: none !important;
            overflow: visible !important;
            --bs-card-bg: #f8f9fa;
            background-color: #f8f9fa !important;
            background: #f8f9fa !important;
            border: 2px dashed #ced4da !important;
        }

        @media (min-width: 576px) {
            #upload-section #dropArea.upload-area,
            #upload-section #dropArea .card-body,
            #upload-section #dropArea .upload-row-wrap,
            #upload-section #dropArea .d-flex.justify-content-center {
                overflow: visible !important;
            }
        }

        @media (min-width: 992px) {
            #upload-section #dropArea.upload-area {
                padding-block: 0.75rem 0.5rem !important;
                padding-inline: 1.55rem !important;
                overflow: visible !important;
            }
        }

        @media (max-width: 575.98px) {
            #upload-section #dropArea.upload-area {
                width: 100%;
                padding: 1rem !important;
                overflow: visible !important;
            }
            #upload-section #dropArea .card-body,
            #upload-section #dropArea .upload-row-wrap {
                overflow: visible !important;
            }
        }

        #upload-section #dropArea .card-body {
            padding: 0.3rem 0.85rem 0.2rem;
            overflow: visible !important;
            width: 100%;
            background: transparent !important;
        }

        #upload-section #dropArea .upload-row-wrap {
            overflow: visible !important;
            width: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
        }
