* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

:root {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --accent-color: #10b981;
    --accent-hover: #059669;
    --card-shadow: 0 4px 6px rgba(0,0,0,0.07);
    --card-hover-shadow: 0 10px 25px rgba(0,0,0,0.12);
    --border-color: #e5e7eb;
}

[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --text-primary: #eaeaea;
    --text-secondary: #a0a0a0;
    --accent-color: #10b981;
    --accent-hover: #059669;
    --card-shadow: 0 4px 6px rgba(0,0,0,0.3);
    --card-hover-shadow: 0 10px 25px rgba(0,0,0,0.5);
    --border-color: #2d3748;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

/* the header section */
.header {
    background: var(--bg-secondary);
    box-shadow: var(--card-shadow);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.nav-links a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover { color: var(--accent-color); }

.theme-toggle {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.theme-toggle:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* the container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.hero {
    text-align: center;
    padding: 3rem 1rem 2rem;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

.privacy-badge {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-color);
    padding: 0.8rem 1.5rem;
    border-radius: 30px;
    display: inline-block;
    margin-top: 1.5rem;
    font-weight: 600;
    border: 2px solid rgba(16, 185, 129, 0.2);
}

.section-title {
    text-align: center;
    font-size: 2rem;
    margin: 3rem 0 2rem;
}

/* the tool cards section */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.tool-card {
    background: var(--bg-secondary);
    border-radius: 14px;
    padding: 2rem;
    box-shadow: var(--card-shadow);
    cursor: pointer;
    text-align: center;
    border: 1px solid var(--border-color);
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* the gradient border hover effect */
.tool-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 14px;
    padding: 1px;
    background: linear-gradient(135deg, #10b981, #3b82f6);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    -webkit-mask: linear-gradient(#fff 0 0) content-box,
                  linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box,
          linear-gradient(#fff 0 0);
    mask-composite: exclude;
}

.tool-card:hover::before { opacity: 1; }

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 45px rgba(16, 185, 129, 0.25);
}

.tool-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2rem;
}

.tool-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #3b82f6;
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.tool-card h3 {
    font-size: 1.3rem;
    margin-bottom: 0.8rem;
}

.tool-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.tool-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    width: 100%;
    transition: all 0.3s;
}

.tool-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

/* the feature section */
.features-section {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 3rem;
    margin: 4rem 0;
    box-shadow: var(--card-shadow);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.feature-item {
    text-align: center;
    padding: 1.5rem;
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.feature-item h4 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.feature-item p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* blog section */
.blog-section {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 4rem 3rem;
    margin: 4rem 0;
    box-shadow: var(--card-shadow);
}

.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.blog-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
}

.blog-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.15);
}

.blog-card h3 {
    color: var(--text-primary);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    line-height: 1.4;
    font-weight: 600;
}

.blog-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    flex-grow: 1;
}

.blog-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
    align-self: flex-start;
}

.blog-link:hover { 
    color: #059669; 
    gap: 0.8rem; 
}

.blog-link::after { 
    content: '→'; 
    transition: transform 0.3s; 
}

.blog-link:hover::after { 
    transform: translateX(4px); 
}

/* how it works section */
.how-it-works-section {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 4rem 3rem;
    margin: 4rem 0;
    box-shadow: var(--card-shadow);
}

.steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.step-card {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    text-align: center;
    transition: all 0.3s;
}

.step-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.2);
}

.step-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    display: block;
}

.step-card h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.step-card p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* the tools section */
.tool-page-hero {
    text-align: center;
    padding: 2.5rem 1rem 1.5rem;
}

.tool-page-hero h1 {
    font-size: 2.2rem;
    margin-bottom: 0.8rem;
}

.tool-page-hero p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 580px;
    margin: 0 auto;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 1rem;
    transition: color 0.3s;
}

.back-link:hover { color: var(--accent-color); }

.tool-workspace {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 3rem;
}

/* the drop zone */
.drop-zone {
    border: 3px dashed var(--accent-color);
    border-radius: 12px;
    padding: 4rem 2rem;
    background: var(--bg-primary);
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.drop-zone.drag-over {
    background: rgba(16, 185, 129, 0.1);
    transform: scale(1.02);
}

.drop-zone:hover { background: rgba(16, 185, 129, 0.05); }

.upload-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    display: block;
}

.drop-zone h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.drop-zone p { color: var(--text-secondary); }

input[type="file"] { 
    display: none; 
}

/* buttons */
.btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.8rem 1.8rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-danger { 
    background: #ef4444; 
}

.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-secondary { 
    background: var(--text-secondary); 
}

.btn-secondary:hover {
    background: #4b5563;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* info box */
.info-box {
    background: rgba(16, 185, 129, 0.1);
    padding: 1.2rem 1.5rem;
    border-radius: 10px;
    border-left: 4px solid var(--accent-color);
    margin-bottom: 1.8rem;
}

.info-box p { 
    margin-bottom: 0.3rem; 
}

.info-box p:last-child {
    margin-bottom: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* toolbar */
.toolbar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

/* Page cards  (used in split, reorder, delete) */
.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.page-card {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.page-card:hover {
    box-shadow: var(--card-hover-shadow);
    border-color: var(--accent-color);
    transform: translateY(-3px);
}

.page-card.selected {
    border-color: var(--accent-color);
    background: rgba(16, 185, 129, 0.08);
}

.page-card.selected-delete {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.07);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.page-preview {
    width: 100%;
    border-radius: 8px;
    background: white;
    display: block;
}

.page-number {
    text-align: center;
    font-weight: 600;
    margin-top: 0.6rem;
}

/* Page Badges  (small labels on page cards) */
.page-badge {
    position: absolute;
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 7px;
    font-weight: 700;
    font-size: 0.8rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.badge-top-right { 
    top: 10px; 
    right: 10px; 
}

.badge-top-left  { 
    top: 10px; 
    left: 10px; 
}

.badge-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.badge-green { 
    background: var(--accent-color); 
}

.badge-gray  { 
    background: var(--text-secondary); 
}

.badge-red   { 
    background: #ef4444; 
}

.badge-blue  { 
    background: #3b82f6; 
}

/* loading spinner */
.loading-box {
    text-align: center;
    padding: 3rem;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* result box */
.result-box {
    text-align: center;
    padding: 2.5rem 1rem;
}

.result-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
}

.result-box h3 {
    color: var(--accent-color);
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.result-stats {
    background: rgba(16, 185, 129, 0.1);
    padding: 1.4rem 1.8rem;
    border-radius: 12px;
    margin: 1.5rem auto;
    max-width: 420px;
    text-align: left;
}

.result-stats p {
    margin-bottom: 0.45rem;
}

.result-stats p:last-child { 
    margin-bottom: 0; 
}

.stat-highlight {
    color: var(--accent-color);
    font-weight: 700;
}

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* toast notifications */
.toast {
    position: fixed;
    top: 88px;
    right: 20px;
    background: var(--accent-color);
    color: white;
    padding: 0.9rem 1.8rem;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    pointer-events: none;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* merge file list */
.merge-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
}

.merge-file-meta {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.merge-file-index {
    color: var(--accent-color);
    font-weight: bold;
    font-size: 1.2rem;
    min-width: 24px;
}

.merge-file-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.merge-file-size {
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin-top: 0.1rem;
}

.merge-file-actions {
    display: flex;
    gap: 0.4rem;
}

.btn-icon {
    background: var(--text-secondary);
    color: white;
    border: none;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.2s;
}

.btn-icon:hover { 
    opacity: 0.8; 
}

.btn-icon-danger { 
    background: #ef4444; 
}

.btn-icon:disabled { 
    opacity: 0.3; 
    cursor: not-allowed; 
}

/* password form */
.form-group { margin-bottom: 1.4rem; }

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* quality selection */
.quality-options {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 1.5rem 0;
}

.quality-btn {
    padding: 0.7rem 1.4rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.25s;
}

.quality-btn:hover,
.quality-btn.active {
    border-color: var(--accent-color);
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-color);
}

/* reorder cards */
.reorder-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    cursor: grab;
    transition: all 0.2s;
    position: relative;
}

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

.reorder-card.dragging {
    opacity: 0.4;
    transform: scale(0.96);
}

.reorder-card.drag-target {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
}

.reorder-card img {
    width: 100%;
    border-radius: 8px;
    margin-top: 2.8rem;
}

/* split cards */
.split-card {
    background: var(--bg-secondary);
    border: 3px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
}

.split-card.file1 {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.split-card img {
    width: 100%;
    border-radius: 8px;
    margin-top: 2.6rem;
}

/* split results */
.split-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    max-width: 780px;
    margin: 0 auto 2rem;
}

.split-result-card {
    padding: 2rem;
    border-radius: 12px;
    border: 2px solid;
    text-align: center;
}

/* modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    padding: 2rem;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    padding: 2.5rem;
    border-radius: 16px;
    max-width: 800px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h2 { 
    margin-bottom: 1.5rem; 
}

.modal-content h3 { 
    margin-top: 2rem; 
    margin-bottom: 1rem; 
}

.modal-content p,
.modal-content ul {
    color: var(--text-secondary);
    line-height: 1.7;
}

.modal-content ul {
    margin: 1rem 0;
    padding-left: 1.2rem;
}

.modal-content li { 
    margin-bottom: 0.4rem; 
}

.close-modal {
    float: right;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    transition: color 0.3s;
}

.close-modal:hover { 
    color: var(--text-primary); 
}

/* blog modal dark background for contrast */
#blogModal .modal-content { background: #0f172a; }
#blogModal h2             { color: #ffffff; }
#blogModal p,
#blogModal li             { color: #e5e7eb !important; }
#blogModal strong         { color: #ffffff; }
#blogModal ul             { padding-left: 1.2rem; }

/* footer */
.footer {
    background: var(--bg-secondary);
    padding: 2rem;
    text-align: center;
    margin-top: 4rem;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.footer p {
    color: var(--text-secondary);
    margin: 0.4rem 0;
}

/* responsive adjustments */
@media (max-width: 768px) {
    .hero h1            { font-size: 2rem; }
    .tool-page-hero h1  { font-size: 1.8rem; }
    .nav-links          { gap: 1rem; font-size: 0.9rem; }
    .tools-grid         { grid-template-columns: 1fr; }
    .toolbar            { flex-direction: column; }
    .result-actions     { flex-direction: column; }
    .btn                { width: 100%; }
    .quality-options    { flex-direction: column; align-items: center; }
    .blog-section       { padding: 2rem 1.5rem; }
    .features-section   { padding: 2rem 1.5rem; }
    .how-it-works-section { padding: 2rem 1.5rem; }
    .tool-workspace     { padding: 1.5rem; }
}