* { margin: 0; padding: 0; box-sizing: border-box; }
        body { background: #f8fafc; font-family: Inter, system-ui, -apple-system, sans-serif; color: #1e293b; line-height: 1.5; }
        :root { --primary: #fa5252; --primary-dark: #e03131; --primary-soft: #fff0f0; --card-border: #e2e8f0; --text-muted: #475569; }
        .container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
        
        .header { background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(4px); border-bottom: 1px solid var(--card-border); position: sticky; top: 0; z-index: 100; }
        .navbar { display: flex; align-items: center; justify-content: space-between; height: 70px; gap: 24px; }
        .logo { font-size: 1.75rem; font-weight: 700; color: #1e293b; text-decoration: none; }
        .logo span { font-weight: 800; color: var(--primary); }
        
        .app-drawer-btn { background: var(--primary-soft); border: none; width: 44px; height: 44px; border-radius: 28px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1.5rem; color: var(--primary); transition: 0.2s; }
        .app-drawer-btn:hover { background: #ffe3e3; transform: scale(1.02); }
        .drawer-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(3px); z-index: 1000; visibility: hidden; opacity: 0; transition: 0.2s; }
        .drawer-overlay.active { visibility: visible; opacity: 1; }
        .app-drawer { position: fixed; top: 80px; right: 24px; width: 320px; background: white; border-radius: 32px; box-shadow: 0 25px 40px -12px rgba(0,0,0,0.25); padding: 20px 16px; z-index: 1001; transform: scale(0.95); opacity: 0; transition: 0.2s; pointer-events: none; border: 1px solid var(--card-border); }
        .drawer-overlay.active .app-drawer { transform: scale(1); opacity: 1; pointer-events: auto; }
        .drawer-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid #fff0f0; margin-bottom: 16px; }
        .close-drawer { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--text-muted); }
        .apps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 8px; }
        .app-item { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 4px; border-radius: 16px; text-decoration: none; color: #304159; transition: 0.2s; }
        .app-item:hover { background: #f1f5f9; }
        .app-icon { width: 48px; height: 48px; background: #fff0f0; border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: var(--primary); }
        .app-name { font-size: 0.7rem; font-weight: 500; text-align: center; }
        
        .tool-wrapper { padding: 48px 0 64px; }
        .tool-card { background: white; border-radius: 32px; box-shadow: rgba(0,0,0,0.05) 0 10px 30px; padding: 32px; }
        .tool-header { display: flex; align-items: center; gap: 20px; margin-bottom: 32px; }
        .tool-icon { width: 80px; height: 80px; background: #fff0f0; border-radius: 24px; display: flex; align-items: center; justify-content: center; font-size: 38px; }
        .tool-header h1 { font-size: 36px; margin-bottom: 8px; }
        .tool-header p { color: var(--text-muted); }
        
        .upload-area { border: 2px dashed #ffc9c9; border-radius: 28px; background: #fff8f8; min-height: 260px; padding: 30px; cursor: pointer; text-align: center; display: flex; align-items: center; justify-content: center; position: relative; transition: 0.25s; }
        .upload-area:hover, .upload-area.dragging { border-color: #fa5252; background: #fff0f0; }
        
        .preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; width: 100%; }
        .preview-card { background: white; border-radius: 22px; border: 1px solid #e5e7eb; position: relative; transition: 0.25s; box-shadow: 0 2px 10px rgba(0,0,0,0.04); cursor: grab; }
        .preview-card:active { cursor: grabbing; }
        .preview-thumb { height: 240px; background: #f9fafb; border-radius: 22px 22px 0 0; display: flex; align-items: center; justify-content: center; overflow: hidden; border-bottom: 1px solid #f1f5f9; }
        .preview-thumb canvas { width: 100%; height: auto; }
        .preview-info { padding: 16px; text-align: left; }
        .preview-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; word-break: break-word; color: #1e293b; }
        .preview-meta { color: var(--text-muted); font-size: 12px; }
        .preview-remove { position: absolute; top: -10px; right: -10px; width: 28px; height: 28px; border-radius: 50%; background: #ef4444; color: white; border: none; cursor: pointer; font-weight: bold; box-shadow: 0 2px 8px rgba(239,68,68,0.3); transition: 0.2s; z-index: 10; }
        .preview-remove:hover { background: #dc2626; transform: scale(1.1); }
        
        .add-more { display: flex; justify-content: center; margin-top: 24px; }
        .add-btn { background: var(--primary-soft); color: var(--primary); border: 1px solid #ffc9c9; padding: 14px 28px; border-radius: 16px; font-weight: 700; cursor: pointer; transition: 0.2s; }
        .add-btn:hover { background: #ffe3e3; }
        
        .add-more { align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
        .sort-control { display:flex; align-items:center; gap:8px; }
        .sort-control label { display:flex; align-items:center; gap:6px; color:var(--text-muted); font-size:13px; font-weight:700; }
        .sort-control label i { color:var(--primary); }
        .sort-control select { height:44px; padding:0 34px 0 13px; border:1px solid #ffc9c9; border-radius:13px; background:#fff; color:#334155; font-size:13px; font-weight:600; outline:none; cursor:pointer; }
        .sort-control select:focus { border-color:#fa5252; box-shadow:0 0 0 3px rgba(79,70,229,.10); }

        .merge-btn { width: 100%; margin-top: 30px; background: #fa5252; color: white; border: none; padding: 20px; border-radius: 20px; font-size: 18px; font-weight: 700; cursor: pointer; transition: 0.25s; }
        .merge-btn:hover { background: #e03131; }
        .merge-btn:disabled { opacity: 0.5; cursor: not-allowed; }
        
        .progress { margin-top: 24px; display: none; }
        .bar { width: 100%; height: 16px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
        .fill { width: 0%; height: 100%; background: #fa5252; transition: 0.25s; }
        .progress-text { margin-top: 8px; font-size: 14px; color: var(--text-muted); }
        
        .download { margin-top: 28px; display: none; }
        .download a { display: flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; background: #10b981; color: white; padding: 20px; border-radius: 20px; font-weight: 700; transition: 0.2s; }
        .download a:hover { background: #059669; }
        
        .footer { background: #0f172a; color: #cbd5e1; padding: 48px 0 32px; margin-top: 48px; }
        .footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 32px; margin-bottom: 48px; }
        .footer-col h4 { color: white; margin-bottom: 18px; }
        .footer-col ul { list-style: none; }
        .footer-col li { margin-bottom: 10px; }
        .footer-col a { color: #94a1b8; text-decoration: none; font-size: 0.85rem; }
        .copyright { text-align: center; padding-top: 32px; border-top: 1px solid #1e293b; font-size: 0.75rem; }
        
        @media (max-width: 768px) {
            .tool-header { flex-direction: column; text-align: center; }
            .tool-header h1 { font-size: 28px; }
            .tool-card { padding: 22px; }
            .app-drawer { right: 16px; left: 16px; width: auto; top: 70px; }
            .add-more { flex-direction:column; align-items:stretch; }
            .add-btn { width:100%; }
            .sort-control { width:100%; justify-content:space-between; }
            .sort-control select { flex:1; }
        }
    
/* Tools4Pdf alignment normalization */
html,body{width:100%;overflow-x:hidden}
main{width:100%;min-width:0}
.container{width:100%}
img,canvas,svg{max-width:100%}
button,input,select,textarea{max-width:100%}
.tool,.tool-wrapper,.tool-shell,.shell,.content-grid{width:100%;box-sizing:border-box}
.tool-card,.card,.converter-card,.content-card{width:100%;min-width:0;box-sizing:border-box}
.settings,.features,.footer-grid{min-width:0}
.settings>* ,.features>* ,.footer-grid>*{min-width:0}
.actions{align-items:stretch}
@media(max-width:760px){
  .container{width:100%;}
  .tool,.tool-wrapper,.tool-shell,.shell,.content-grid{max-width:100%;}
  .tool-card,.card,.converter-card,.content-card{max-width:100%;}
}

/* Merge PDF reliability improvements; keeps the original visual design. */
.preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    image-rendering: auto;
}
.preview-remove:focus-visible,
.add-btn:focus-visible,
.merge-btn:focus-visible,
.sort-control select:focus-visible,
.app-drawer-btn:focus-visible,
.download a:focus-visible {
    outline: 3px solid rgba(250, 82, 82, 0.45);
    outline-offset: 3px;
}
.merge-status {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid #ffc9c9;
    border-radius: 14px;
    background: #fff8f8;
    color: #7f1d1d;
    font-size: 14px;
    overflow-wrap: anywhere;
}
.merge-status[hidden] { display: none !important; }
.merge-status.success {
    border-color: #a7f3d0;
    background: #ecfdf5;
    color: #065f46;
}
.merge-status.info {
    border-color: #cbd5e1;
    background: #f8fafc;
    color: #334155;
}

