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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 50%, #7f1d1d 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(220, 38, 38, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(153, 27, 27, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    padding: 40px 30px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.header h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 15px;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.4);
    letter-spacing: -1px;
    background: linear-gradient(135deg, #ffffff 0%, #fecaca 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.95;
    font-weight: 300;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.card {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    padding: 35px;
    margin-bottom: 25px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25), 0 5px 15px rgba(220, 38, 38, 0.2);
    animation: slideUp 0.4s ease-out;
    border: 1px solid rgba(220, 38, 38, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3), 0 8px 20px rgba(220, 38, 38, 0.3);
}

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

.card h2 {
    font-size: 2rem;
    margin-bottom: 25px;
    color: #dc2626;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card h2::before {
    content: '';
    width: 4px;
    height: 30px;
    background: linear-gradient(135deg, #dc2626, #991b1b);
    border-radius: 2px;
}

.source-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.option-card {
    border: 3px solid #fee2e2;
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%);
    position: relative;
    overflow: hidden;
}

.option-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(220, 38, 38, 0.1), transparent);
    transition: left 0.5s ease;
}

.option-card:hover::before {
    left: 100%;
}

.option-card:hover {
    border-color: #dc2626;
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 10px 30px rgba(220, 38, 38, 0.3);
    background: linear-gradient(135deg, #ffffff 0%, #fee2e2 100%);
}

.option-card.selected {
    border-color: #dc2626;
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    box-shadow: 0 8px 25px rgba(220, 38, 38, 0.25);
}

.option-icon {
    font-size: 3.5rem;
    margin-bottom: 15px;
    filter: drop-shadow(2px 2px 4px rgba(220, 38, 38, 0.2));
}

.option-card h3 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    color: #991b1b;
    font-weight: 600;
}

.option-card p {
    color: #7f1d1d;
    font-size: 0.95rem;
    line-height: 1.5;
}

.input-section {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 2px solid #fee2e2;
}

.input-group {
    margin-bottom: 25px;
}

.input-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #991b1b;
    font-size: 1.05rem;
}

.input-field {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #fee2e2;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #ffffff;
    color: #333;
}

.input-field:focus {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.1);
    background: #fef2f2;
}

.input-group small {
    display: block;
    margin-top: 8px;
    color: #7f1d1d;
    font-size: 0.9rem;
    font-style: italic;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.btn-warning:hover {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.btn-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.btn-info:hover {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.btn-google {
    background: linear-gradient(135deg, #4285f4 0%, #1a73e8 100%);
    color: white;
}

.btn-google:hover {
    background: linear-gradient(135deg, #5a9ef4 0%, #4285f4 100%);
    transform: translateY(-3px);
}

.btn-large {
    padding: 18px 40px;
    font-size: 1.2rem;
    border-radius: 12px;
}

.gallery-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    margin-bottom: 30px;
    padding: 20px;
    background: #fef2f2;
    border-radius: 12px;
    border: 2px solid #fee2e2;
}

#page-info {
    font-weight: 600;
    font-size: 1.2rem;
    color: #991b1b;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 25px;
}

.gallery-item {
    border: 3px solid #fee2e2;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.gallery-item:hover {
    transform: translateY(-8px) scale(1.03);
    box-shadow: 0 12px 30px rgba(220, 38, 38, 0.3);
    border-color: #dc2626;
}

.gallery-item img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.gallery-item .item-label {
    padding: 15px;
    text-align: center;
    font-weight: 600;
    color: #991b1b;
    background: #fef2f2;
}

.crop-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}

.crop-image-wrapper {
    position: relative;
    border: 3px solid #fee2e2;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

#crop-image {
    max-width: 100%;
    height: auto;
    display: block;
}

#crop-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.crop-controls {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.preview-section {
    border: 3px solid #fee2e2;
    border-radius: 16px;
    padding: 20px;
    background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.preview-section h3 {
    margin-bottom: 20px;
    font-size: 1.3rem;
    color: #dc2626;
    font-weight: 700;
}

#crop-preview {
    width: 100%;
    aspect-ratio: 1;
    border: 3px solid #dc2626;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
}

#crop-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.matching-section {
    text-align: center;
    padding: 40px;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-radius: 16px;
    border: 2px solid #fee2e2;
}

.matching-section p {
    font-size: 1.3rem;
    margin-bottom: 30px;
    color: #991b1b;
    font-weight: 500;
}

.progress-bar {
    width: 100%;
    height: 35px;
    background: #fee2e2;
    border-radius: 18px;
    overflow: hidden;
    margin: 25px 0;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid #fecaca;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #dc2626, #ef4444, #dc2626);
    background-size: 200% 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 18px;
    animation: shimmer 2s infinite;
    box-shadow: 0 2px 10px rgba(220, 38, 38, 0.5);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

#progress-text {
    margin-top: 15px;
    font-weight: 600;
    color: #991b1b;
    font-size: 1.1rem;
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 25px;
    margin-bottom: 35px;
}

.stat-card {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 50%, #7f1d1d 100%);
    color: white;
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(220, 38, 38, 0.3);
    transition: transform 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.stat-card:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 12px 35px rgba(220, 38, 38, 0.4);
}

.stat-value {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.stat-label {
    font-size: 1.1rem;
    opacity: 0.95;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.results-table-container {
    overflow-x: auto;
    margin-top: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 2px solid #fee2e2;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.results-table th {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: white;
    padding: 18px;
    text-align: left;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
}

.results-table td {
    padding: 15px 18px;
    border-bottom: 2px solid #fee2e2;
}

.results-table tr:hover {
    background: #fef2f2;
    transform: scale(1.01);
    transition: all 0.2s ease;
}

.results-table tr:last-child td {
    border-bottom: none;
}

.results-table .match-yes {
    color: #059669;
    font-weight: 700;
    font-size: 1.05rem;
}

.results-table .match-no {
    color: #dc2626;
    font-weight: 600;
}

.similarity-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.similarity-high {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 2px solid #10b981;
}

.similarity-medium {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border: 2px solid #f59e0b;
}

.similarity-low {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 2px solid #dc2626;
}

.export-section {
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-radius: 16px;
    border: 2px solid #fee2e2;
}

#export-status {
    margin-top: 25px;
    padding: 18px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1.05rem;
}

.export-success {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 2px solid #10b981;
}

.export-error {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 2px solid #dc2626;
}

.auth-section {
    margin-bottom: 30px;
    padding: 25px;
    background: #fef2f2;
    border-radius: 12px;
    border: 2px solid #fee2e2;
}

#auth-status {
    margin-top: 20px;
    padding: 15px;
    border-radius: 10px;
    font-weight: 600;
}

.auth-success-msg {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 2px solid #10b981;
}

.auth-error-msg {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 2px solid #dc2626;
}

.auth-success {
    text-align: center;
    max-width: 500px;
    margin: 100px auto;
}

@media (max-width: 768px) {
    .crop-container {
        grid-template-columns: 1fr;
    }
    
    .source-options {
        grid-template-columns: 1fr;
    }
    
    .header h1 {
        font-size: 2.2rem;
    }
    
    .card {
        padding: 25px;
    }
    
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
}

/* ---- Google Drive picker ---- */
.drive-trail {
    padding: 10px 14px;
    margin-bottom: 18px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    font-size: 14px;
    color: #7f1d1d;
    overflow-x: auto;
    white-space: nowrap;
}

.drive-trail a {
    color: #dc2626;
    text-decoration: none;
    font-weight: 600;
}

.drive-trail a:hover {
    text-decoration: underline;
}

.drive-list {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 6px;
}

.drive-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 8px;
}

.drive-row:hover {
    background: #fef2f2;
}

.drive-row a {
    color: #991b1b;
    text-decoration: none;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
    max-height: 340px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid #fecaca;
    border-radius: 10px;
}

.drive-cell {
    position: relative;
    aspect-ratio: 1 / 1;
    border: 3px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: #fef2f2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    word-break: break-all;
    padding: 4px;
}

.drive-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.drive-cell.picked {
    border-color: #dc2626;
}

/* a tick that reads without relying on colour alone */
.drive-cell.picked::after {
    content: '\2713';
    position: absolute;
    top: 4px;
    right: 6px;
    color: #fff;
    background: #dc2626;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

.drive-selection {
    margin: 16px 0 12px;
    font-weight: 600;
    color: #7f1d1d;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .drive-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }
}
