    /* ── Full-Page Editor Mode ── */
    body.editor-active {
        overflow: hidden !important;
        height: 100vh !important;
    }

    body.editor-active header,
    body.editor-active .md\:hidden.sticky,
    body.editor-active footer {
        display: none !important;
    }

    body.editor-active .flex.flex-col.lg\:flex-row {
        height: 100vh !important;
        overflow: hidden !important;
    }

    body.editor-active .tool-page-container {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        height: 100% !important;
        overflow: hidden !important;
    }

    body.editor-active .tool-page-container>.animate-in {
        height: 100% !important;
    }

    body.editor-active .lg\:w-72 {
        display: none !important;
    }

    body.editor-active .animate-in {
        animation: none !important;
    }

    body.editor-active .bg-\[\#f8fafd\] {
        background: #f8fafc !important;
    }

    body.editor-active .flex-1.min-w-0 {
        overflow: hidden !important;
        height: 100% !important;
    }

    #pdf-editor-app {
        display: none;
    }

    #pdf-editor-app.active {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    /* ── Toolbar ── */
    .editor-toolbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 8px 16px;
        background: #fff;
        border-bottom: 1px solid #e2e8f0;
        position: sticky;
        top: 0;
        z-index: 40;
        min-height: 52px;
    }

    .toolbar-left {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-shrink: 0;
    }

    #toolbar-file-name {
        font-size: 14px;
        color: #1e293b;
        font-weight: 600;
        max-width: 160px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .toolbar-center {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 2px;
        padding: 0 8px;
        min-width: 0;
    }

    .toolbar-center>* {
        flex-shrink: 0;
    }

    .toolbar-right {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }

    .toolbar-sep {
        width: 1px;
        height: 28px;
        background: #e2e8f0;
        margin: 0 2px;
    }

    /* ── Tool Buttons ── */
    .tb-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 8px 14px;
        border-radius: 9999px;
        border: 1px solid transparent;
        font-size: 13px;
        font-weight: 600;
        color: #475569;
        cursor: pointer;
        background: transparent;
        transition: all 0.15s;
        white-space: nowrap;
    }

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

    .tb-btn.active {
        background: #2f76ff;
        color: #fff;
        border-color: #2f76ff;
    }

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

    .tb-btn.btn-download {
        background: #2f76ff;
        color: #fff;
        border-color: #2f76ff;
        font-weight: 700;
        padding-left: 20px;
        padding-right: 20px;
    }

    .tb-btn.btn-download:hover {
        background: #1d4ed8;
        border-color: #1d4ed8;
    }

    .tb-btn.btn-download svg {
        color: #fff;
    }

    .tb-btn.btn-start-over {
        background: #f8fafc;
        color: #64748b;
        border: 1px solid #e2e8f0;
    }

    .tb-btn.btn-start-over:hover {
        background: #f1f5f9;
        color: #ef4444;
        border-color: #fee2e2;
    }

    /* Hide specific tool labels on desktop (they will show in mobile wrench menu) */
    #btn-undo span, 
    #btn-redo span, 
    #btn-delete span {
        display: none;
    }

    /* ── Toolbar Options (inline) ── */
    .tb-opts {
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

    .tb-opts label {
        font-size: 12px;
        color: #64748b;
        font-weight: 600;
    }

    .tb-opts input[type="color"] {
        width: 28px;
        height: 28px;
        border: 2px solid #e2e8f0;
        border-radius: 6px;
        padding: 0;
        cursor: pointer;
        background: none;
    }

    .tb-opts input[type="color"]::-webkit-color-swatch-wrapper {
        padding: 1px;
    }

    .tb-opts input[type="color"]::-webkit-color-swatch {
        border: none;
        border-radius: 4px;
    }

    .tb-opts input[type="range"] {
        width: 80px;
        accent-color: #2f76ff;
    }

    .tb-opts input[type="number"] {
        width: 52px;
        padding: 4px 6px;
        border: 1px solid #e2e8f0;
        border-radius: 6px;
        font-size: 12px;
        background: #f8fafc;
        color: #334155;
        text-align: center;
    }

    .tb-opts input[type="checkbox"] {
        accent-color: #2f76ff;
    }

    .tb-opts .opt-val {
        font-size: 11px;
        color: #2f76ff;
        font-weight: 700;
        min-width: 20px;
    }

    .tb-opts-group {
        display: none;
    }

    /* ── Wrench / Tools menu (hidden by default, shown by JS on mobile) ── */
    #toolbar-more {
        display: none;
        position: relative;
    }

    #toolbar-more.visible {
        display: block;
    }

    /* ── More Menu Dropdown ── */
    #more-menu {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        min-width: 200px;
        background: #fff;
        border-radius: 12px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
        padding: 8px;
        flex-direction: column;
        gap: 2px;
        z-index: 1000;
        margin-top: 8px;
        border: 1px solid #e2e8f0;
    }

    #more-menu.open {
        display: flex;
    }

    #more-menu .tb-btn {
        width: 100%;
        justify-content: flex-start;
        padding: 10px 14px;
        border-radius: 8px;
        background: transparent !important;
        color: #475569 !important;
        font-size: 14px;
        border: none;
    }

    #more-menu .tb-btn:hover {
        background: #f1f5f9 !important;
        color: #2f76ff !important;
    }

    #more-menu .tb-btn.active {
        background: #eff6ff !important;
        color: #2f76ff !important;
    }

    #more-menu .tb-btn span {
        display: inline !important;
        margin-left: 8px;
        font-weight: 500;
    }

    #more-menu .tb-btn svg {
        width: 18px;
        height: 18px;
    }

    #more-menu .toolbar-sep {
        height: 1px !important;
        width: calc(100% - 16px) !important;
        margin: 6px 8px !important;
        background: #e2e8f0 !important;
        display: block !important;
    }

    #more-menu .flex.items-center {
        width: 100%;
        padding: 6px 12px;
        justify-content: space-between;
    }

    #more-menu .shape-dropdown {
        width: 100%;
        display: block !important;
    }

    #more-menu .shape-dropdown .tb-btn {
        width: 100% !important;
        justify-content: flex-start !important;
    }

    /* ═══════════════════════════════════════════════════════
       STAGE 2: ICONS ONLY (768px – 1200px)
       Hide labels on center toolbar buttons, compact padding
       ═══════════════════════════════════════════════════════ */
    @media (max-width: 1400px) {

        .toolbar-center .tb-btn span,
        .toolbar-center .shape-dropdown .tb-btn span {
            display: none;
        }

        .toolbar-center .tb-btn {
            padding: 8px 10px;
            gap: 0;
        }

        /* Also compact right-side labels */
        .toolbar-right .btn-start-over span,
        .toolbar-right .btn-download span {
            display: none;
        }

        .toolbar-right .btn-start-over,
        .toolbar-right .btn-download {
            padding: 8px 12px;
        }

        #toolbar-file-name {
            max-width: 100px;
        }
    }

    /* ═══════════════════════════════════════════════════════
       STAGE 3: WRENCH ONLY (< 768px)
       Hide all center tools, show wrench button via JS
       ═══════════════════════════════════════════════════════ */
    @media (max-width: 1024px) {
        .toolbar-center > .tool-item {
            display: none !important;
        }

        .toolbar-center > .toolbar-sep {
            display: none !important;
        }

        .toolbar-left .logo-text {
            display: none !important;
        }

        #toolbar-file-name {
            max-width: 80px;
            font-size: 12px;
        }

        .editor-toolbar {
            padding: 6px 10px;
        }
    }

    /* ── Workspace ── */
    .editor-workspace {
        display: flex;
        flex: 1;
        min-height: 0;
        /* critical for flex child to respect overflow */
        overflow: hidden;
        background: #f1f5f9;
    }

    /* ── Thumbnails Sidebar ── */
    .thumb-sidebar {
        width: 160px;
        min-width: 160px;
        background: #f8fafc;
        padding: 0;
        display: flex;
        flex-direction: column;
        scrollbar-width: thin;
        scrollbar-color: #cbd5e1 transparent;
        border-right: 1px solid #e2e8f0;
        height: 100%;
        max-height: calc(100vh - 56px);
        overflow: hidden; /* container doesn't scroll, thumb-list does */
    }

    .add-pdf-btn {
        width: calc(100% - 20px);
        margin: 10px;
        padding: 12px;
        background: #fff;
        border: 2px dashed #cbd5e1;
        border-radius: 12px;
        color: #64748b;
        font-size: 13px;
        font-weight: 700;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        cursor: pointer;
        transition: all 0.2s;
        flex-shrink: 0;
    }

    .add-pdf-btn:hover {
        border-color: #2f76ff;
        color: #2f76ff;
        background: #eff6ff;
        transform: translateY(-1px);
    }

    .add-pdf-btn svg {
        width: 20px;
        height: 20px;
    }

    #thumb-list {
        flex: 1;
        overflow-y: auto;
        padding: 0 10px 16px 10px;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    @media (max-width: 1024px) {
        .thumb-sidebar {
            width: 100%;
            min-width: unset;
            height: 154px;
            min-height: 154px;
            flex-direction: row;
            overflow-x: hidden;
            overflow-y: hidden;
            border-right: none;
            border-bottom: 1px solid #e2e8f0;
        }

        .add-pdf-btn {
            width: 60px;
            height: 80px;
            min-width: 60px;
            padding: 8px;
            margin: 10px 0 10px 10px;
            justify-content: center;
            font-size: 10px;
        }

        #thumb-list {
            flex-direction: row;
            overflow-x: auto;
            overflow-y: hidden;
            padding: 10px;
            gap: 8px;
            align-items: center;
        }

        .thumb-item canvas {
            width: 100% !important;
            height: auto !important;
        }
    }

    .thumb-sidebar::-webkit-scrollbar {
        width: 4px;
    }

    .thumb-sidebar::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 4px;
    }

    .thumb-item {
        cursor: grab;
        border: 2px solid #e2e8f0;
        border-radius: 6px;
        /* overflow: hidden; Removed so dropdowns can pop out */
        transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
        position: relative;
        background: #fff;
        flex-shrink: 0;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    }

    .thumb-item:hover {
        border-color: #2f76ff;
    }

    .thumb-item.active {
        border-color: #2f76ff;
        box-shadow: 0 0 0 3px rgba(47, 118, 255, 0.25);
    }

    .thumb-item.dragging {
        opacity: 0.4;
        border-color: #94a3b8;
    }

    .thumb-item.drag-over-top {
        border-top: 3px solid #2f76ff;
    }

    .thumb-item.drag-over-bottom {
        border-bottom: 3px solid #2f76ff;
    }

    .thumb-item canvas {
        display: block;
        width: 100%;
        height: auto;
        pointer-events: none;
        border-radius: 4px;
        /* compensate for removing overflow:hidden on parent */
    }

    /* ── Thumb Menu (3-dots) ── */
    .thumb-menu-btn {
        position: absolute;
        top: 4px;
        right: 4px;
        width: 28px;
        height: 20px;
        background: rgba(0, 0, 0, 0.45);
        color: #fff;
        border-radius: 6px;
        display: none;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 20;
        transition: all 0.2s;
    }

    .thumb-menu-btn:hover {
        background: rgba(0, 0, 0, 0.7);
    }

    .thumb-menu-btn svg {
        width: 16px;
        height: 16px;
    }

    .thumb-item:hover .thumb-menu-btn,
    .thumb-menu-btn.open {
        display: flex;
    }

    .thumb-dropdown {
        position: fixed;
        /* Positioned dynamically via JS on click */
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
        width: 170px;
        z-index: 99999;
        display: none;
        flex-direction: column;
        padding: 8px 0;
    }

    .thumb-dropdown.open {
        display: flex;
    }

    .thumb-dropdown-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 16px;
        font-size: 14px;
        font-weight: 500;
        color: #334155;
        cursor: pointer;
        background: transparent;
        border: none;
        width: 100%;
        text-align: left;
        transition: all 0.1s;
    }

    .thumb-dropdown-item:hover {
        background: #f8fafc;
        color: #2f76ff;
    }

    .thumb-dropdown-item:hover svg {
        color: #2f76ff;
    }

    .thumb-dropdown-item svg {
        width: 18px;
        height: 18px;
        color: #94a3b8;
    }

    .thumb-dropdown-item:disabled {
        opacity: 0.3;
        cursor: not-allowed;
    }

    .thumb-dropdown-item:disabled:hover {
        background: transparent;
        color: #334155;
    }

    .thumb-dropdown-item:disabled:hover svg {
        color: #94a3b8;
    }

    .thumb-dropdown-sep {
        height: 1px;
        background: #f1f5f9;
        margin: 6px 12px;
    }

    .thumb-label {
        position: absolute;
        bottom: 2px;
        left: 2px;
        right: 0;
        background: rgba(0, 0, 0, 0.55);
        color: #ffffff;
        font-size: 10px;
        font-weight: 700;
        text-align: center;
        padding: 2px 0;
        letter-spacing: 0.05em;
        width: 20px;
        border-radius: 4px;
        pointer-events: none;
    }

    /* ── Canvas Area ── */
    .canvas-area {
        flex: 1;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        overflow: auto;
        padding: 24px;
        position: relative;
        background: #f1f5f9;
    }

    .canvas-wrapper {
        position: relative;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
        border-radius: 2px;
        overflow: visible;
        background: #fff;
        flex-shrink: 0;
    }

    /* Fix Fabric.js canvas container stacking */
    .canvas-wrapper .canvas-container {
        display: block !important;
    }

    /* ── Shape Sub-Selector ── */
    .shape-dropdown {
        position: relative;
        display: inline-block;
    }

    .shape-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        padding: 6px;
        z-index: 50;
        min-width: 140px;
        margin-top: 4px;
    }

    .shape-menu.open {
        display: block;
    }

    .shape-menu-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-radius: 6px;
        font-size: 13px;
        font-weight: 600;
        color: #475569;
        cursor: pointer;
        transition: all 0.1s;
    }

    .shape-menu-item:hover {
        background: #f1f5f9;
        color: #1e293b;
    }

    .shape-menu-item svg {
        width: 16px;
        height: 16px;
    }

    /* ── Signature Modal ── */
    .sig-modal {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 9999;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(6px);
        align-items: center;
        justify-content: center;
        padding: 24px;
    }

    .sig-modal.open {
        display: flex;
    }

    .sig-modal-inner {
        background: #fff;
        border-radius: 1.5rem;
        padding: 32px;
        width: 100%;
        max-width: 500px;
        box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
    }

    .sig-modal-inner h3 {
        font-size: 18px;
        font-weight: 800;
        color: #1e293b;
        margin-bottom: 16px;
    }

    .sig-canvas-wrap {
        border: 2px dashed #cbd5e1;
        border-radius: 12px;
        overflow: hidden;
        margin-bottom: 16px;
        background: #fafafa;
    }

    .sig-btns {
        display: flex;
        gap: 10px;
        justify-content: flex-end;
    }

    .sig-btns button {
        padding: 10px 24px;
        border-radius: 9999px;
        font-weight: 700;
        font-size: 13px;
        cursor: pointer;
        transition: all 0.15s;
    }

    .sig-btn-cancel {
        background: #f1f5f9;
        color: #475569;
        border: 1px solid #e2e8f0;
    }

    .sig-btn-cancel:hover {
        background: #e2e8f0;
    }

    .sig-btn-clear {
        background: #fee2e2;
        color: #dc2626;
        border: 1px solid #fecaca;
    }

    .sig-btn-clear:hover {
        background: #fecaca;
    }

    .sig-btn-insert {
        background: #2f76ff;
        color: #fff;
        border: 1px solid #2f76ff;
    }

    .sig-btn-insert:hover {
        background: #2563eb;
    }

    /* ── Zoom Badge ── */
    .zoom-badge {
        position: absolute;
        bottom: 12px;
        right: 12px;
        background: #fff;
        color: #475569;
        font-size: 11px;
        font-weight: 700;
        padding: 4px 10px;
        border-radius: 6px;
        pointer-events: none;
        z-index: 10;
        border: 1px solid #e2e8f0;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    }

    /* Page info in bottom-left */
    .page-info-badge {
        position: absolute;
        bottom: 12px;
        left: 12px;
        background: #fff;
        color: #64748b;
        font-size: 11px;
        font-weight: 600;
        padding: 4px 10px;
        border-radius: 6px;
        pointer-events: none;
        z-index: 10;
        border: 1px solid #e2e8f0;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    }

    .page-info-badge strong {
        color: #1e293b;
    }

    /* ── Responsive ── */
    @media (max-width: 1024px) {
        .thumb-menu-btn {
            display: flex;
        }

        .thumb-dropdown {
            left: 0;
            top: calc(100% + 5px);
            width: 160px;
        }

        .editor-workspace {
            flex-direction: column;
        }

        .thumb-sidebar {
            width: 100%;
            min-width: unset;
            height: 140px;
            min-height: 140px;
            flex-direction: row;
            overflow-x: auto;
            overflow-y: hidden;
            border-right: none;
            border-bottom: 1px solid #e2e8f0;
            padding: 8px;
            gap: 8px;
        }

        .thumb-sidebar::-webkit-scrollbar {
            height: 3px;
            width: auto;
        }

        .thumb-item {
            width: 70px;
            min-width: 70px;
            flex-shrink: 0;
        }

        .thumb-item.drag-over-top {
            border-top: none;
            border-left: 3px solid #2f76ff;
        }

        .thumb-item.drag-over-bottom {
            border-bottom: none;
            border-right: 3px solid #2f76ff;
        }

        .canvas-area {
            padding: 10px;
        }

        .editor-toolbar {
            gap: 2px;
            padding: 6px 8px;
        }

        .tb-btn {
            padding: 5px 7px;
            font-size: 12px;
        }

        .tb-btn span {
            display: none;
        }

        .tb-opts {
            display: none;
        }

        .toolbar-center {
            justify-content: center;
        }
    }

    /* ── Toolbar Flex Sections ── */
    .editor-toolbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 8px 16px;
        background: #fff;
        border-bottom: 1px solid #e2e8f0;
        position: sticky;
        top: 0;
        z-index: 100;
        height: 56px;
        width: 100%;
        overflow: visible;
    }

    .toolbar-left,
    .toolbar-right {
        display: flex;
        align-items: center;
        gap: 12px;
        flex-shrink: 0;
    }

    .toolbar-center {
        display: flex;
        align-items: center;
        gap: 4px;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        white-space: nowrap;
    }

    #toolbar-file-name {
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-weight: 600;
        color: #1e293b;
        font-size: 14px;
        border-left: 1px solid #e2e8f0;
        padding-left: 12px;
    }

    /* More Dropdown */
    .more-dropdown {
        position: relative;
    }

    .more-menu {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        padding: 8px;
        z-index: 110;
        min-width: 160px;
        margin-top: 8px;
    }

    .more-menu.open {
        display: block;
    }

    .more-menu .tb-btn {
        width: 100%;
        justify-content: flex-start;
    }

    .more-menu .tb-btn span {
        display: inline !important;
    }

    .more-menu .toolbar-sep {
        width: 100%;
        height: 1px;
        margin: 8px 0;
    }

    /* Floating Sub-Toolbar */
    #sub-toolbar {
        position: fixed;
        top: 68px;
        /* Below 56px toolbar + 12px gap */
        left: 50%;
        transform: translateX(-50%);
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 9999px;
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
        padding: 6px 16px;
        z-index: 90;
        display: none;
        align-items: center;
        gap: 12px;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        animation: subToolbarSlideIn 0.3s ease-out;
    }

    @keyframes subToolbarSlideIn {
        from {
            transform: translate(-50%, -10px);
            opacity: 0;
        }

        to {
            transform: translate(-50%, 0);
            opacity: 1;
        }
    }

    #sub-toolbar.active {
        display: flex;
    }

    .sub-toolbar .tb-opts {
        display: none;
        align-items: center;
        gap: 12px;
        white-space: nowrap;
    }

    .sub-toolbar label {
        font-size: 11px;
        font-weight: 700;
        color: #64748b;
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }

    /* ── SEO sections shown when editor is NOT active ── */
    #editor-seo-content {
        display: block;
    }

    body.editor-active #editor-seo-content {
        display: none;
    }
