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

:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: #d1fae5;
    --secondary: #6366f1;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #475569;
    --danger: #ef4444;
    --success: #22c55e;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --radius: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 120px;
    min-height: 100vh;
}

/* Header */
header {
    text-align: center;
    padding: 24px 0;
    margin-bottom: 8px;
}

.header-logo {
    width: 72px;
    height: auto;
    margin-bottom: 12px;
    filter: drop-shadow(0 4px 12px rgba(16, 185, 129, 0.3));
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Section Cards */
.section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.hidden {
    display: none !important;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 16px;
    background: var(--bg-input);
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 16px;
    color: var(--text);
    transition: all 0.3s ease;
}

.form-group input::placeholder {
    color: var(--text-secondary);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(16, 185, 129, 0.1);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

/* Button Styles */
.btn {
    padding: 16px 28px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    width: 100%;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-primary:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    width: 100%;
    margin-top: 16px;
}

.btn-outline:active {
    background: rgba(16, 185, 129, 0.1);
}

.icon {
    font-size: 1.3rem;
}

/* Capture Button */
.btn-capture {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 4px solid var(--primary);
    position: relative;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3), inset 0 2px 10px rgba(0,0,0,0.3);
}

.btn-capture::after {
    content: '';
    position: absolute;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.2s ease;
}

.btn-capture:active::after {
    transform: translate(-50%, -50%) scale(0.9);
}

/* Camera Styles */
.info-bar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 14px 20px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-weight: 600;
    text-align: center;
    font-size: 0.95rem;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.photo-count {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-left: 8px;
}

.camera-wrapper {
    position: relative;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 3/4;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

#camera-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.camera-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 16px;
    gap: 16px;
}

/* Flash Effect */
.flash-effect {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    animation: flash 0.15s ease-out;
    pointer-events: none;
}

@keyframes flash {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Batch Strip */
.batch-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-input);
    border-radius: 12px;
    margin-top: 12px;
}

.batch-thumbnails {
    display: flex;
    gap: 8px;
    flex: 1;
    overflow-x: auto;
}

.batch-thumb {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.batch-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.more-count {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.btn-small {
    padding: 10px 16px;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Batch Review Section */
.batch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.batch-header h2 {
    font-size: 1.1rem;
    margin: 0;
}

#batch-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.batch-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.batch-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.batch-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.delete-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: transform 0.2s;
}

.delete-btn:active {
    transform: scale(0.9);
}

.photo-number {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(0,0,0,0.7);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.batch-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.batch-actions .btn {
    flex: 1;
}

/* Preview Styles */
.preview-wrapper {
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

#preview-image {
    width: 100%;
    display: block;
}

.preview-controls {
    display: flex;
    gap: 12px;
}

.preview-controls .btn {
    flex: 1;
}

.next-action {
    margin-top: 8px;
}

/* Gallery Styles */
#gallery-section {
    background: transparent;
    box-shadow: none;
    border: none;
    padding: 16px 0;
}

#gallery-section h2 {
    font-size: 0.85rem;
    margin-bottom: 16px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

#gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.gallery-item {
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.gallery-item:active {
    transform: scale(0.95);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 2px dashed var(--border);
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.spinner {
    width: 56px;
    height: 56px;
    border: 4px solid rgba(16, 185, 129, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

#loading-overlay p {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text);
    padding: 14px 28px;
    border-radius: 12px;
    z-index: 1001;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    font-weight: 500;
}

.toast.success {
    background: linear-gradient(135deg, var(--success) 0%, #16a34a 100%);
    border: none;
}

.toast.error {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    border: none;
}

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

/* Photo Viewer */
.photo-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.photo-viewer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.close-viewer {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.close-viewer:active {
    background: rgba(255,255,255,0.2);
}

/* Responsive */
@media (max-width: 380px) {
    .container {
        padding: 12px;
    }
    
    header h1 {
        font-size: 1.3rem;
    }
    
    .section {
        padding: 20px;
    }
    
    .btn {
        padding: 14px 20px;
        font-size: 14px;
    }
    
    .btn-capture {
        width: 66px;
        height: 66px;
    }
    
    .btn-capture::after {
        width: 48px;
        height: 48px;
    }
}

@media (min-width: 481px) {
    .container {
        padding: 24px;
    }
    
    .section {
        padding: 32px;
    }
    
    #gallery-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Safe area for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
    .container {
        padding-top: calc(16px + env(safe-area-inset-top));
        padding-bottom: calc(120px + env(safe-area-inset-bottom));
    }
}
