﻿/* Main Workspace Container */
        .workspace {
            max-width: 1200px;
            width: 100%;
            margin: 1.5rem auto 4rem;
            padding: 0 1.5rem;
            display: flex;
            flex-direction: column;
            gap: 1.75rem;
        }

        /* Glassmorphic Cards */
        .glass-card {
            background: var(--bg-card);
            backdrop-filter: blur(20px);
            border: 1px solid var(--border-glass);
            border-radius: var(--radius-xl);
            padding: 2rem;
            box-shadow: var(--shadow-card);
            position: relative;
        }

        .glass-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 1px;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
        }

        /* Drop Zone */
        .dropzone {
            border: 2px dashed rgba(168, 85, 247, 0.35);
            border-radius: var(--radius-lg);
            padding: 3.5rem 2rem;
            text-align: center;
            background: rgba(17, 24, 39, 0.4);
            cursor: pointer;
            transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
            position: relative;
            outline: none;
        }

        .dropzone:hover, .dropzone.dragover {
            border-color: #a855f7;
            background: rgba(168, 85, 247, 0.08);
            box-shadow: 0 0 35px -8px rgba(168, 85, 247, 0.35);
            transform: translateY(-2px);
        }

        .dropzone-icon {
            width: 76px;
            height: 76px;
            border-radius: 50%;
            background: rgba(168, 85, 247, 0.12);
            color: #c084fc;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 2.25rem;
            margin: 0 auto 1.5rem;
            border: 1px solid rgba(168, 85, 247, 0.25);
            transition: transform 0.25s ease;
        }

        .dropzone:hover .dropzone-icon {
            transform: scale(1.08);
            color: #e9d5ff;
        }

        .dropzone-title {
            font-size: 1.35rem;
            font-weight: 700;
            margin-bottom: 0.5rem;
        }

        .dropzone-sub {
            color: var(--text-muted);
            font-size: 0.95rem;
            margin-bottom: 1.25rem;
        }

        .btn-choose {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.75rem 1.6rem;
            border-radius: var(--radius-md);
            background: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
            color: #fff;
            font-weight: 600;
            font-size: 0.92rem;
            border: none;
            cursor: pointer;
            box-shadow: 0 4px 15px rgba(168, 85, 247, 0.35);
            transition: all 0.2s ease;
        }

        .btn-choose:hover {
            box-shadow: 0 6px 20px rgba(168, 85, 247, 0.5);
            transform: translateY(-1px);
        }

        .file-input {
            display: none;
        }

        /* Organizer Toolbar */
        .organizer-toolbar {
            display: none;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 1rem;
            padding: 1rem 1.4rem;
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid var(--border-glass);
            border-radius: var(--radius-md);
            margin-bottom: 1.75rem;
        }

        .toolbar-left {
            display: flex;
            align-items: center;
            gap: 1rem;
            flex-wrap: wrap;
        }

        .page-counter-badge {
            display: inline-flex;
            align-items: center;
            gap: 0.45rem;
            padding: 0.35rem 0.85rem;
            border-radius: var(--radius-sm);
            background: rgba(99, 102, 241, 0.15);
            border: 1px solid rgba(99, 102, 241, 0.3);
            font-size: 0.88rem;
            font-weight: 700;
            color: #a5b4fc;
        }

        .toolbar-actions {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            flex-wrap: wrap;
        }

        .btn-tool {
            display: inline-flex;
            align-items: center;
            gap: 0.45rem;
            padding: 0.55rem 0.95rem;
            border-radius: var(--radius-sm);
            background: rgba(255, 255, 255, 0.05);
            color: var(--text-main);
            border: 1px solid var(--border-glass);
            font-size: 0.82rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .btn-tool:hover {
            background: rgba(255, 255, 255, 0.12);
            border-color: rgba(255, 255, 255, 0.2);
            transform: translateY(-1px);
        }

        .btn-tool-add {
            background: rgba(16, 185, 129, 0.15);
            border-color: rgba(16, 185, 129, 0.3);
            color: #34d399;
        }

        .btn-tool-add:hover {
            background: rgba(16, 185, 129, 0.25);
            color: #fff;
        }

        .btn-tool-danger {
            background: rgba(244, 63, 94, 0.1);
            border-color: rgba(244, 63, 94, 0.25);
            color: #fb7185;
        }

        .btn-tool-danger:hover {
            background: rgba(244, 63, 94, 0.2);
            color: #fff;
        }

        /* Pages Grid */
        .pages-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
            gap: 1.5rem;
            min-height: 160px;
        }

        /* Page Card */
        .page-card {
            background: rgba(15, 23, 42, 0.85);
            border: 1px solid var(--border-glass);
            border-radius: var(--radius-md);
            padding: 0.9rem;
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
            cursor: grab;
            transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
            position: relative;
            user-select: none;
        }

        .page-card:hover {
            border-color: rgba(168, 85, 247, 0.5);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
            transform: translateY(-3px);
        }

        .page-card:active {
            cursor: grabbing;
        }

        .page-card.sortable-ghost {
            opacity: 0.3;
            border: 2px dashed #a855f7;
            background: rgba(168, 85, 247, 0.1);
        }

        .page-card.sortable-chosen {
            box-shadow: 0 0 25px rgba(168, 85, 247, 0.6);
        }

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

        .page-number-tag {
            font-size: 0.76rem;
            font-weight: 700;
            background: rgba(255, 255, 255, 0.08);
            color: var(--text-main);
            padding: 0.2rem 0.55rem;
            border-radius: 999px;
            font-family: 'JetBrains Mono', monospace;
        }

        .page-source-tag {
            font-size: 0.7rem;
            color: var(--text-dim);
            max-width: 110px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .page-thumbnail-box {
            background: #fff;
            border-radius: var(--radius-sm);
            aspect-ratio: 1 / 1.414; /* Standard A4 aspect ratio */
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            position: relative;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
            transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        }

        .page-thumbnail-box canvas {
            max-width: 100%;
            max-height: 100%;
            object-fit: contain;
            display: block;
        }

        .page-thumbnail-box .loading-spinner {
            color: #6366f1;
            font-size: 1.5rem;
        }

        .page-controls {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-top: 0.25rem;
            border-top: 1px solid rgba(255, 255, 255, 0.05);
        }

        .btn-page-ctrl {
            background: transparent;
            border: none;
            color: var(--text-muted);
            width: 32px;
            height: 32px;
            border-radius: var(--radius-sm);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.88rem;
            transition: all 0.15s ease;
        }

        .btn-page-ctrl:hover {
            background: rgba(255, 255, 255, 0.08);
            color: var(--text-main);
        }

        .btn-page-ctrl.ctrl-delete:hover {
            background: rgba(244, 63, 94, 0.15);
            color: #fb7185;
        }

        /* Bottom Merge Bar */
        .bottom-bar {
            display: none;
            position: sticky;
            bottom: 1.5rem;
            z-index: 90;
            background: rgba(17, 24, 39, 0.9);
            backdrop-filter: blur(20px);
            border: 1px solid rgba(168, 85, 247, 0.35);
            border-radius: var(--radius-lg);
            padding: 1.25rem 2rem;
            box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.7);
            align-items: center;
            justify-content: space-between;
            flex-wrap: wrap;
            gap: 1.25rem;
            animation: fadeIn 0.3s ease;
        }

        .bottom-info {
            display: flex;
            align-items: center;
            gap: 1.25rem;
        }

        .bottom-title h4 {
            font-size: 1.1rem;
            font-weight: 700;
        }

        .bottom-title p {
            font-size: 0.85rem;
            color: var(--text-muted);
        }

        .btn-merge {
            display: inline-flex;
            align-items: center;
            gap: 0.65rem;
            padding: 0.95rem 2.4rem;
            border-radius: var(--radius-md);
            background: var(--accent-gradient);
            color: #fff;
            font-size: 1.05rem;
            font-weight: 700;
            border: none;
            cursor: pointer;
            box-shadow: 0 6px 25px rgba(168, 85, 247, 0.4);
            transition: all 0.25s ease;
        }

        .btn-merge:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 8px 30px rgba(168, 85, 247, 0.6);
        }

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

        /* Progress Card */
        .progress-card {
            display: none;
            animation: fadeIn 0.3s ease;
        }

        .progress-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
        }

        .progress-title {
            font-size: 1.1rem;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .progress-track {
            width: 100%;
            height: 10px;
            border-radius: 5px;
            background: rgba(255, 255, 255, 0.06);
            overflow: hidden;
        }

        .progress-bar-fill {
            height: 100%;
            width: 0%;
            background: var(--accent-gradient);
            border-radius: 5px;
            transition: width 0.25s ease;
        }

        /* Results Card */
        .results-card {
            display: none;
            animation: fadeIn 0.4s ease;
            text-align: center;
            padding: 3rem 2rem;
            background: linear-gradient(180deg, rgba(17, 24, 39, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
            border: 1px solid rgba(16, 185, 129, 0.3);
        }

        .results-icon {
            width: 72px;
            height: 72px;
            border-radius: 50%;
            background: rgba(16, 185, 129, 0.15);
            color: #34d399;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 2.25rem;
            margin: 0 auto 1.5rem;
            border: 1px solid rgba(16, 185, 129, 0.3);
        }

        .results-title {
            font-size: 1.75rem;
            font-weight: 800;
            margin-bottom: 0.5rem;
        }

        .results-desc {
            color: var(--text-muted);
            font-size: 0.95rem;
            margin-bottom: 1.75rem;
        }

        .btn-download {
            display: inline-flex;
            align-items: center;
            gap: 0.65rem;
            padding: 1rem 2.5rem;
            border-radius: var(--radius-md);
            background: var(--accent-emerald);
            color: #064e3b;
            font-size: 1.1rem;
            font-weight: 800;
            text-decoration: none;
            box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
            transition: all 0.25s ease;
        }

        .btn-download:hover {
            background: #34d399;
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(16, 185, 129, 0.6);
        }

        /* Animations */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(8px); }
            to { opacity: 1; transform: translateY(0); }
        }