:root {
    --bg-color: #f8fafc; /* Slate 50 Light */
    --card-bg: rgba(255, 255, 255, 0.88); /* Clean Frosted Glass */
    --card-border: rgba(226, 232, 240, 0.8); /* Slate 200 */
    --primary: #2563eb; /* Blue 600 */
    --primary-hover: #1d4ed8; /* Blue 700 */
    --primary-light: #eff6ff; /* Blue 50 */
    --text-main: #0f172a; /* Slate 900 */
    --text-muted: #64748b; /* Slate 500 */
    --text-subtle: #94a3b8; /* Slate 400 */
    --success: #059669; /* Emerald 600 */
    --warning: #d97706; /* Amber 600 */
    --danger: #dc2626; /* Red 600 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.06), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 20px 30px -10px rgba(37, 99, 235, 0.12);
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
    line-height: 1.5;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 820px;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

header {
    text-align: center;
    animation: fadeInDown 0.8s ease-out;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.logo svg {
    filter: drop-shadow(0 2px 8px rgba(37, 99, 235, 0.25));
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.05rem;
    font-weight: 400;
}

/* Light Glassmorphism Panels */
.controls-panel, .upload-section, .preview-section {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 1.1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    animation: fadeInUp 0.8s ease-out;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Controls Panel */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.control-group label {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-main);
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 0.6rem;
    width: max-content;
    padding: 0.35rem 0.85rem;
    transition: all 0.25s ease;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-wrapper input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-family);
    font-size: 1.25rem;
    font-weight: 600;
    width: 85px;
    outline: none;
    text-align: right;
    padding-right: 0.5rem;
}

.input-wrapper .unit {
    color: var(--text-muted);
    font-weight: 600;
}

.control-group small {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Split Protection Badge */
.split-badge {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: rgba(37, 99, 235, 0.06);
    border: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: 0.75rem;
    padding: 0.85rem 1rem;
    margin-top: 0.75rem;
    color: #1e40af;
    font-size: 0.875rem;
    line-height: 1.45;
}

.split-badge svg {
    flex-shrink: 0;
    color: var(--primary);
    margin-top: 0.1rem;
}

/* Upload Dropzone */
.dropzone {
    border: 2px dashed #93c5fd;
    border-radius: 0.85rem;
    padding: 3rem 1rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    background: rgba(239, 246, 255, 0.5);
}

.dropzone:hover, .dropzone.dragover {
    background: rgba(219, 234, 254, 0.7);
    border-color: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.08);
}

.drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    pointer-events: none;
}

.drop-content svg {
    color: var(--primary);
    transition: transform 0.3s ease;
}

.dropzone:hover .drop-content svg {
    transform: translateY(-5px);
}

.drop-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

.drop-content p {
    color: var(--text-muted);
}

.hidden-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Preview Section */
.preview-header {
    margin-bottom: 1rem;
}

.preview-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
}

.preview-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.preview-card {
    position: relative;
    border-radius: 0.6rem;
    overflow: hidden;
    aspect-ratio: 3/4;
    background: #f1f5f9;
    border: 2px solid #e2e8f0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
    cursor: grab;
}

.preview-card:hover {
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

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

.preview-card.dragging {
    opacity: 0.6;
    transform: scale(1.05);
    z-index: 10;
    border-color: var(--primary);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.preview-grid.drag-over-active .preview-card:not(.dragging) {
    transition: transform 0.2s ease;
}

.file-name {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(15, 23, 42, 0.75);
    color: #ffffff;
    font-size: 0.7rem;
    padding: 0.35rem 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    backdrop-filter: blur(4px);
    text-align: left;
    z-index: 1;
}

.preview-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25), 0 6px 16px rgba(37, 99, 235, 0.12);
}

.preview-card.unselected {
    opacity: 0.45;
    filter: grayscale(80%);
}

.preview-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.preview-card:hover img {
    transform: scale(1.04);
}

.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(15, 23, 42, 0.45) 0%, transparent 40%, transparent 60%, rgba(15, 23, 42, 0.65) 100%);
    pointer-events: none;
}

.page-num {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: rgba(15, 23, 42, 0.75);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 0.3rem;
    backdrop-filter: blur(4px);
    z-index: 2;
}

.check-icon {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
    z-index: 2;
}

.preview-card.selected .check-icon {
    opacity: 1;
    transform: scale(1);
}

/* Action Footer */
.action-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #ffffff;
    border: none;
    border-radius: 2rem;
    padding: 1rem 3.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 220px;
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
}

.primary-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.primary-btn:disabled {
    background: #cbd5e1;
    color: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.8;
}

/* Spinner Animation */
.spinner {
    animation: rotate 2s linear infinite;
    z-index: 2;
    width: 24px;
    height: 24px;
}

.spinner .path {
    stroke: #ffffff;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate {
    100% { transform: rotate(360deg); }
}

@keyframes dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

/* App Footer */
.app-footer {
    text-align: center;
    padding: 1.5rem 0 1rem;
    color: var(--text-muted);
    font-size: 0.925rem;
    font-weight: 500;
    border-top: 1px solid rgba(203, 213, 225, 0.5);
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.app-footer strong {
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Status Alert Message */
.status-alert {
    width: 100%;
    max-width: 600px;
    padding: 0.9rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 0.925rem;
    line-height: 1.5;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    animation: fadeInUp 0.4s ease-out;
}

.status-alert.success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.status-alert.warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.status-alert.info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 640px) {
    h1 { font-size: 2rem; }
    .controls-panel, .upload-section, .preview-section {
        padding: 1rem;
    }
    .preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    }
}

/* --- Light Liquid Pastel Ambient Blobs --- */
.liquid-blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(95px);
    z-index: -1;
    opacity: 0.45;
    animation: floatBlob 16s infinite ease-in-out alternate;
    pointer-events: none;
}

.blob-1 {
    width: 450px;
    height: 450px;
    background: #93c5fd; /* Soft sky blue */
    top: -120px;
    left: -120px;
    animation-delay: 0s;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: #c4b5fd; /* Soft lavender purple */
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
    animation-direction: alternate-reverse;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: #a7f3d0; /* Soft mint emerald */
    top: 40%;
    left: 25%;
    animation-delay: -10s;
}

@keyframes floatBlob {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(80px, -40px) scale(1.15); }
    66% { transform: translate(-40px, 80px) scale(0.9); }
    100% { transform: translate(0, 0) scale(1); }
}

/* --- 2mm Mouse Trailing Dots --- */
.cursor-dot {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 99999;
    width: 2mm;
    height: 2mm;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    box-shadow: 0 0 4px rgba(37, 99, 235, 0.4);
    will-change: transform, opacity;
    opacity: 0;
    transition: opacity 0.3s ease;
}
