* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex; align-items: center; justify-content: center;
    background-color: #f3f6fc; padding: 10px; min-height: 50vh;
}
.tool-header { text-align: center; margin-bottom: 1rem; }
.tool-header h2 { font-size: 1.8rem; color: #1a2634; margin-bottom: 0.3rem; }
.tool-header p { color: #5c6a7b; font-size: 0.95rem; padding: 10px; }
.merger-pro {
    max-width: 880px; width: 100%; background: #fff;
    border-radius: 28px; box-shadow: 0 20px 40px -12px rgba(0,0,0,0.15);
    padding: 2rem 2rem 2.5rem;
}
.pro-dropzone {
    background: #f9fafc; border-radius: 24px; border: 2px dashed #4CAF50;
    transition: all 0.2s; cursor: pointer; position: relative; margin-bottom: 1.75rem;
}
.pro-dropzone:hover { border-color: #6f7c91; background: #d2dff7; }
.pro-dropzone.highlight { border-color: #1f2b3b; background: #edf2f9; border-style: solid; }
.drop-placeholder { padding: 3rem 2rem; text-align: center; }
.drop-placeholder .icon { font-size: 3.5rem; margin-bottom: 0.75rem; opacity: 0.7; }
.drop-placeholder h3 { font-size: 1.35rem; font-weight: 600; color: #1a2634; margin-bottom: 0.3rem; }
.drop-placeholder p { color: #5c6a7b; font-size: 0.95rem; margin-bottom: 1.5rem; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    border: 1px solid #cad2db; background: #fff; border-radius: 10px;
    padding: 0.7rem 1.6rem; font-weight: 600; font-size: 0.9rem; color: #1f2b3b;
    transition: all 0.2s; cursor: pointer;
}
.btn-primary { background: #4CAF50; color: white; border: none; }
.btn-primary:hover { background: #43A047; transform: translateY(-1px); box-shadow: 0 6px 12px rgba(76,175,80,0.3); }
.btn-outline:hover { background: #f3f6fc; border-color: #8f9fb1; }
.btn-danger { background: #fef2f2; border: 1px solid #fbc5c5; color: #b91c1c; }
.btn-danger:hover { background: #fee2e2; }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.grid-container { padding: 1.5rem 1.5rem 1.2rem; text-align: center; }
.grid-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 1.25rem; font-size: 0.9rem; color: #2f3e4e; font-weight: 500; border-bottom: 1px solid #e4eaf2; padding-bottom: 0.7rem; text-align: left; }
.image-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-bottom: 1.2rem; }
.image-item { width: 80px; height: 80px; flex-shrink: 0; }
.image-item { position: relative; aspect-ratio: 1/1; border-radius: 14px; overflow: hidden; border: 3px solid white; box-shadow: 0 4px 12px rgba(0,0,0,0.06); background: #f1f4f9; }
.image-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-info-overlay { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.7); color: white; font-size: 9px; padding: 4px 2px; text-align: center; line-height: 1.2; pointer-events: none; }
.remove-btn { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; background: #dc2626; color: white; border: none; border-radius: 50%; font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 10; }
.remove-btn:hover { background: #b91c1c; }
.settings-panel { background: #f8fafd; border-radius: 24px; padding: 1.4rem 1.6rem; margin: 1.5rem 0 1.8rem; border: 1px solid #e3eaf2; }
.settings-row { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; justify-content: center; }
.control-group { display: flex; align-items: center; gap: 0.6rem; background: #fff; padding: 0.3rem 0.3rem 0.3rem 1rem; border-radius: 40px; border: 1px solid #dce3ec; }
.control-group label { font-size: 0.85rem; font-weight: 500; color: #40556a; }
.control-group select, .control-group input[type="number"] { border: none; background: #f0f4fa; padding: 0.45rem 1rem; border-radius: 40px; font-size: 0.9rem; color: #1e2b3a; font-weight: 500; outline: none; min-width: 80px; }
.action-buttons { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; }
.action-buttons .btn { min-width: 170px; padding: 0.9rem 1.2rem; }
.pro-loader { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: rgba(255,255,255,0.98); backdrop-filter: blur(8px); padding: 2rem 2.5rem; border-radius: 60px; box-shadow: 0 25px 45px -12px rgba(0,0,0,0.35); z-index: 99999; display: none; flex-direction: column; align-items: center; gap: 0.8rem; }
.pro-loader.active { display: flex; }
.spinner-pro { width: 42px; height: 42px; border: 3px solid #e0e7ef; border-top: 3px solid #4CAF50; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pro-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(20,28,40,0.7); backdrop-filter: blur(5px); display: none; align-items: center; justify-content: center; z-index: 99999; padding: 1rem; }
.pro-modal.active { display: flex; }
.modal-card { background: #fff; max-width: 840px; width: 100%; border-radius: 32px; padding: 2rem 2rem 2.2rem; box-shadow: 0 30px 70px rgba(0,10,30,0.3); text-align: center; position: relative; max-height: 90vh; overflow-y: auto; }
.modal-icon { width: 44px; height: 44px; background: #4CAF50; border-radius: 50%; display: flex; margin: 0 auto 1rem; align-items: center; justify-content: center; color: white; font-size: 24px; }
.modal-title { font-size: 1.5rem; font-weight: 700; color: #101826; margin-bottom: 1.5rem; }
/* FIX 1: Center output results grid like input images */
.results-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin-bottom: 1.5rem; }
.result-item { border-radius: 16px; overflow: hidden; box-shadow: 0 4px 14px rgba(0,0,0,0.1); background: #fff; display: flex; flex-direction: column; width: 170px; flex-shrink: 0; }
.result-thumb-wrap { position: relative; }
.result-item img { width: 100%; height: 120px; object-fit: cover; display: block; }
.result-pdf-thumb { height: 120px; display: flex; align-items: center; justify-content: center; background: #eef2f6; font-size: 2.5rem; }
.size-badge { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.65); color: white; font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.result-name { font-size: 11px; color: #445566; font-weight: 500; padding: 6px 8px 4px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #f8fafd; border-top: 1px solid #edf1f7; }
.result-actions { display: flex; gap: 0; border-top: 1px solid #edf1f7; }
.result-actions .rab { flex: 1; border: none; background: #fff; color: #334455; font-size: 11px; font-weight: 600; padding: 8px 4px; cursor: pointer; transition: background 0.15s, color 0.15s; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.result-actions .rab:not(:last-child) { border-right: 1px solid #edf1f7; }
.result-actions .rab:hover { background: #f0faf0; color: #2e7d32; }
.result-actions .rab.share:hover { background: #e8f4fd; color: #1565c0; }
.result-actions .rab .rab-icon { font-size: 14px; }
.modal-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; margin-top: 0.5rem; }
.flash-close-btn { position: absolute; top: 16px; right: 18px; background: transparent; border: none; font-size: 26px; cursor: pointer; color: #6c7e98; }
.file-input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; overflow: hidden; z-index: -1; }
.rename-modal-bg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(20,28,40,0.6); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 999999; }
.rename-modal-bg.active { display: flex; }
.rename-card { background: #fff; border-radius: 24px; padding: 2rem; box-shadow: 0 20px 50px rgba(0,0,0,0.25); width: 100%; max-width: 380px; text-align: center; }
.rename-card h3 { font-size: 1.1rem; color: #1a2634; margin-bottom: 1rem; }
.rename-input { width: 100%; border: 2px solid #dce3ec; border-radius: 12px; padding: 0.7rem 1rem; font-size: 1rem; color: #1e2b3a; outline: none; margin-bottom: 1.2rem; transition: border-color 0.2s; }
.rename-input:focus { border-color: #4CAF50; }
.rename-actions { display: flex; gap: 0.8rem; justify-content: center; }
@media (max-width: 500px) {
    .action-buttons { flex-direction: column; }
    .action-buttons .btn { width: 100%; }
}