:root {
    --bg-overlay: rgba(0, 0, 0, 0.45);
    --glass-bg: rgba(15, 23, 42, 0.45);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-glow: rgba(56, 189, 248, 0.25);
    --accent-cyan: #38bdf8;
    --accent-cyan-hover: #7dd3fc;
    --accent-purple: #818cf8;
    --accent-green: #34d399;
    --text-primary: #ffffff;
    --text-muted: #94a3b8;
    --font-heading: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

body {
    background: url('bg.png') no-repeat center center fixed;
    background-size: cover;
    color: var(--text-primary);
    font-family: var(--font-body);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.65) 100%);
    pointer-events: none;
    z-index: 1;
}

/* Header & Navbar */
.navbar {
    position: fixed;
    top: max(1.5rem, env(safe-area-inset-top));
    left: max(1.75rem, env(safe-area-inset-left));
    z-index: 100;
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
}

.brand-logo:hover, .brand-logo:active {
    transform: translateY(-2px);
    opacity: 0.9;
}

.brand-logo.small {
    transform: scale(0.9);
}

.logo-icon {
    position: relative;
    width: 44px;
    height: 28px;
    flex-shrink: 0;
}

.logo-icon .pill {
    position: absolute;
    border-radius: 999px;
}

.logo-icon .pill-top {
    width: 32px;
    height: 16px;
    background: linear-gradient(135deg, #4f46e5, #0284c7);
    top: 0;
    left: 0;
    transform: rotate(-10deg);
}

.logo-icon .pill-bottom {
    width: 32px;
    height: 16px;
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    bottom: 0;
    right: 0;
    transform: rotate(-10deg);
    opacity: 0.85;
}

.brand-name {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.3px;
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

/* Main Container */
.main-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 680px;
    padding: 4.5rem 1rem 3.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Hero Section with Fluid Typography */
.hero-section {
    text-align: center;
    margin-bottom: 1.5rem;
}

.hero-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.05;
}

.title-main {
    font-family: var(--font-heading);
    font-size: clamp(2.2rem, 7vw, 3.2rem);
    font-weight: 800;
    letter-spacing: 1.5px;
    color: #ffffff;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.title-sub {
    font-family: var(--font-body);
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    font-weight: 600;
    color: var(--accent-cyan);
    letter-spacing: 0.5px;
    text-shadow: 0 0 15px rgba(56, 189, 248, 0.5);
    margin-top: -2px;
}

/* Quick Action Pill Buttons */
.quick-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.75rem;
    width: 100%;
    max-width: 380px;
    justify-content: center;
}

.btn-pill {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: clamp(0.95rem, 3.5vw, 1.05rem);
    padding: 0.85rem 2rem;
    min-height: 48px; /* Mobile optimal touch target */
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    user-select: none;
}

.btn-pill:active {
    transform: scale(0.97);
}

.btn-cyan {
    background: var(--accent-cyan);
    color: #050b14;
    box-shadow: 0 0 25px rgba(56, 189, 248, 0.45);
}

.btn-cyan:hover:not(:disabled) {
    background: var(--accent-cyan-hover);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 0 35px rgba(56, 189, 248, 0.65);
}

.btn-cyan:disabled {
    background: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.35);
    box-shadow: none;
    cursor: not-allowed;
}

.btn-white {
    background: #ffffff;
    color: #050b14;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.btn-white:hover {
    background: #f8fafc;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.4);
}

.btn-success:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 0 35px rgba(16, 185, 129, 0.6);
}

.btn-glass {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.btn-glass:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-2px);
}

/* Glass Card Dropzone */
.glass-card {
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    padding: clamp(1.25rem, 4vw, 2rem);
    transition: var(--transition);
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.glass-card.dragover {
    border-color: var(--accent-cyan);
    background: rgba(56, 189, 248, 0.14);
    box-shadow: 0 0 35px rgba(56, 189, 248, 0.35);
    transform: scale(1.01);
}

.dropzone-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.upload-icon-box {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-cyan);
    margin-bottom: 0.25rem;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
}

.dropzone-content h3 {
    font-size: clamp(1.05rem, 3.5vw, 1.2rem);
    font-weight: 600;
    color: #ffffff;
}

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

.browse-link {
    color: var(--accent-cyan);
    text-decoration: underline;
    font-weight: 500;
}

.file-specs {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.2rem;
}

/* Preview Stage */
.preview-stage {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.image-box {
    position: relative;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    overflow: hidden;
}

.badge {
    position: absolute;
    top: 10px;
    left: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    z-index: 10;
}

.badge-before, .badge-after {
    color: #ef4444;
}

.image-wrapper {
    position: relative;
    width: 100%;
    max-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    overflow: hidden;
}

.image-wrapper img {
    max-width: 100%;
    max-height: 230px;
    object-fit: contain;
    border-radius: 8px;
    animation: fadeIn 0.4s ease-out forwards;
}

.checkerboard {
    background-color: #111827;
    background-image: linear-gradient(45deg, #1f2937 25%, transparent 25%), 
                      linear-gradient(-45deg, #1f2937 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, #1f2937 75%), 
                      linear-gradient(-45deg, transparent 75%, #1f2937 75%);
    background-size: 16px 16px;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
    box-shadow: 0 0 12px var(--accent-cyan);
    display: none;
}

.scanning .scan-line {
    display: block;
    animation: scanAnimation 2s linear infinite;
}

/* Controls Belt */
.controls-belt {
    display: flex;
    gap: 0.85rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

/* Progress Container */
.progress-container {
    width: 100%;
    margin-top: 1.25rem;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.progress-container.active {
    opacity: 1;
}

.progress-status-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.progress-bar-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    border-radius: 999px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px var(--accent-cyan);
}

/* Footer & About Trigger */
.footer-bottom {
    position: fixed;
    bottom: max(1.5rem, env(safe-area-inset-bottom));
    right: max(1.75rem, env(safe-area-inset-right));
    z-index: 100;
}

.about-trigger-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1.15rem;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.about-trigger-btn:hover, .about-trigger-btn:active {
    color: var(--accent-cyan);
    transform: translateY(-2px);
    text-shadow: 0 0 15px rgba(56, 189, 248, 0.6);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-backdrop.active {
    display: flex;
    animation: fadeIn 0.3s ease-out forwards;
}

.modal-card {
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    padding: clamp(1.25rem, 4vw, 2rem);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover, .modal-close:active {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.08);
}

.modal-header {
    margin-bottom: 1.25rem;
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    color: #ffffff;
}

.modal-body h3 {
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
    color: #ffffff;
}

.modal-body p {
    font-size: 0.92rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

.modal-links {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.modal-link-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.2rem;
    min-height: 48px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    color: #ffffff;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    transition: var(--transition);
}

.modal-link-btn:hover, .modal-link-btn:active {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateX(4px);
}

.modal-link-btn.highlight {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.3);
    color: var(--accent-cyan);
}

.modal-link-btn.highlight:hover, .modal-link-btn.highlight:active {
    background: rgba(56, 189, 248, 0.22);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

.tools-grid {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.tool-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.15rem;
    min-height: 56px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    text-decoration: none;
    color: #ffffff;
    transition: var(--transition);
}

.tool-card:hover, .tool-card:active {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.35);
    transform: translateY(-2px);
}

.tool-icon {
    font-size: 1.4rem;
}

.tool-info h4 {
    font-size: 0.98rem;
    font-weight: 600;
}

.tool-info p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0;
}

.tool-arrow {
    margin-left: auto;
    font-size: 1.2rem;
    color: var(--accent-cyan);
}

/* Mobile Media Queries */
@media (max-width: 640px) {
    .navbar {
        top: max(1.2rem, env(safe-area-inset-top));
        left: max(1.25rem, env(safe-area-inset-left));
    }
    
    .brand-name {
        font-size: 1.05rem;
    }
    
    .footer-bottom {
        bottom: max(1.2rem, env(safe-area-inset-bottom));
        right: max(1.25rem, env(safe-area-inset-right));
    }
    
    .main-container {
        padding-top: 5rem;
        padding-bottom: 4.5rem;
    }

    .quick-actions {
        flex-direction: row;
        gap: 0.75rem;
    }
    
    .quick-actions .btn-pill {
        flex: 1;
        padding: 0.75rem 1rem;
    }
    
    .preview-stage {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }
    
    .image-wrapper {
        max-height: 200px;
    }
    
    .controls-belt .btn-pill {
        width: 100%;
    }
    
    .modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }
    
    .modal-card {
        border-radius: 28px 28px 0 0;
        max-height: 85vh;
        border-bottom: none;
        animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }
}

/* Animations */
@keyframes scanAnimation {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
