:root {
    --primary: #0052D4;
    --primary-hover: #0041a8;
    --accent: #1EAF5B;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --badge-bg: #F0F5FF;
    --radius-lg: 24px;
    --radius-md: 16px;
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Plus Jakarta Sans', sans-serif; -webkit-font-smoothing: antialiased; }
body {
    background-color: var(--bg);
    color: var(--text-main);
    line-height: 1.6;
    background-image: radial-gradient(at 0% 100%, rgba(0, 82, 212, 0.05) 0px, transparent 50%);
}

/* Header */
header {
    padding: 0.75rem 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}
.navbar { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.logo { text-decoration: none; display: flex; align-items: center; }
.main-logo { height: 40px; width: auto; display: block; }
.mobile-logo { display: none; }

@media (max-width: 600px) {
    .main-logo { display: none; }
    .mobile-logo { display: block; height: 32px; width: auto; }
}

/* Container & Typography */
.container { max-width: 1100px; margin: 3rem auto; padding: 0 1.5rem; text-align: center; }
.header-section { margin-bottom: 3rem; }
h1 { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 0.5rem; }
.subtitle { color: var(--text-muted); font-size: 1.1rem; }

/* Drop Zone */
.drop-zone {
    background: var(--card-bg);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 4rem 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2.5rem;
}
.drop-zone:hover { border-color: var(--primary); background: #fdf2f1; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.drop-icon { font-size: 3rem; margin-bottom: 1rem; }
.drop-text { font-size: 1.25rem; font-weight: 700; color: var(--text-main); margin-bottom: 0.5rem; }
.drop-info { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; }
#file-input { display: none; }

/* Selection Controls */
.selection-controls { margin-bottom: 1.5rem; display: flex; justify-content: center; gap: 1rem; }
.btn-secondary { background: white; border: 1px solid var(--border); padding: 0.6rem 1.2rem; border-radius: 12px; font-weight: 700; color: var(--text-main); cursor: pointer; transition: all 0.2s; font-size: 0.875rem; }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); background: #f5f3ff; }

/* Pages Grid */
.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.page-item {
    background: var(--card-bg);
    padding: 12px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
}

.page-item:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--border); }

.page-item.selected {
    border-color: var(--primary);
    background-color: #f5f3ff;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.page-thumb {
    width: 100%;
    aspect-ratio: 1 / 1.414;
    background-color: #f1f5f9;
    margin-bottom: 12px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.page-thumb img { width: 100%; height: 100%; object-fit: contain; }

.page-number { font-weight: 800; font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; }
.page-item.selected .page-number { color: var(--primary); }

.check-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--primary);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4);
    z-index: 2;
    border: 2px solid white;
}
.page-item.selected .check-badge { display: flex; }

/* Output Container */
.output-container { max-width: 600px; margin: 0 auto; }
.settings-card {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.group-title { font-size: 0.875rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 1.25rem; display: block; }

.mode-selection { display: flex; flex-direction: column; gap: 1rem; }
.mode-option {
    display: flex;
    align-items: flex-start;
    padding: 1.25rem;
    border: 2px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
}
.mode-option:hover { border-color: var(--primary); background: #f8fafc; }
.mode-option.active { border-color: var(--primary); background: #f5f3ff; }

.mode-option input[type="radio"] { margin-top: 4px; margin-right: 1.25rem; accent-color: var(--primary); width: 20px; height: 20px; flex-shrink: 0; }
.mode-content { display: flex; flex-direction: column; gap: 4px; }
.mode-title { font-weight: 800; font-size: 1rem; color: var(--text-main); }
.mode-desc { font-size: 0.875rem; color: var(--text-muted); line-height: 1.4; }

.modern-input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 600;
    background: #f8fafc;
    transition: all 0.2s;
}
.modern-input:focus { outline: none; border-color: var(--primary); background: white; box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1); }

.btn-action {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    border: none;
    padding: 1.25rem;
    border-radius: 16px;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    width: 100%;
}
.btn-action:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4); }
.btn-action:disabled { background: #cbd5e1; cursor: not-allowed; box-shadow: none; opacity: 0.7; }

#status { margin-top: 1rem; font-size: 0.95rem; font-weight: 700; color: var(--primary); }

.btn-text-action {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}
.btn-text-action:hover { background: var(--badge-bg); }

.btn-clear-data {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff1f2;
    color: #e11d48;
    border: 1px solid #fecdd3;
    padding: 8px 16px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-clear-data:hover {
    background: #ffe4e6;
    border-color: #fda4af;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.15);
}


@media (max-width: 640px) {
    h1 { font-size: 2rem; }
    .pages-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
    .settings-card { padding: 1.5rem; }
}
