:root {
    --apple-blue: #007AFF;
    --apple-gray: #8E8E93;
    --apple-gray-light: #F2F2F7;
    --apple-label: #000000;
    --apple-secondary-label: #3C3C43;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Performance optimizations */
.camera-preview video,
.camera-preview img,
.result-image {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

.capture-button,
.close-result-btn,
.download-button {
    will-change: transform;
}

.processing,
.result-section {
    contain: layout style paint;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: #f5f5f7;
    color: #1d1d1f;
    min-height: 100vh;
    line-height: 1.47059;
    font-weight: 400;
    letter-spacing: -0.022em;
}

.app-container {
    width: 100%;
    height: 100vh;
    background: #9e86ff;
    position: relative;
    overflow: hidden;
}

.static-title {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 40px 16px 8px;
    z-index: 200;
    text-align: center;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(80px);
    -webkit-backdrop-filter: blur(80px);
}

.static-title h1 {
    font-size: 72px;
    font-weight: 600;
    color: #6e47ae;
    letter-spacing: -0.003em;
    text-shadow: 2px 2px 8px rgb(255, 255, 255);
}

.camera-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
}

.camera-preview {
    width: 100%;
    height: 100vh;
    border: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    background: #000000;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
}

.camera-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
}

.camera-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
}

.camera-preview .placeholder {
    text-align: center;
    color: #86868b;
}

.camera-preview .placeholder i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    color: #86868b;
}

.camera-preview .placeholder p {
    font-size: 17px;
    font-weight: 400;
    color: #86868b;
}

.camera-preview .loading {
    text-align: center;
    color: #86868b;
}

.camera-preview .loading i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    animation: pulse 2s infinite;
    color: #007aff;
}

.camera-preview .loading p {
    font-size: 17px;
    font-weight: 400;
    color: #86868b;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.camera-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 104px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.2), transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.capture-button {
    width: 80px;
    height: 80px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    position: relative;
}

.capture-button:hover {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 1);
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.capture-button:active {
    transform: scale(0.98);
    transition-duration: 0.1s;
}

.camera-error {
    text-align: center;
    padding: 32px 20px;
    color: #ff3b30;
}

.camera-error i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    color: #ff3b30;
}

.camera-error p {
    font-size: 17px;
    font-weight: 400;
    margin-bottom: 12px;
    color: #1d1d1f;
}

.camera-error small {
    font-size: 15px;
    color: #86868b;
    display: block;
    margin-bottom: 20px;
}

.camera-error button {
    background: #007aff;
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.camera-error button:hover {
    background: #0056d6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.processing {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    border-radius: 20px;
    padding: 40px 32px;
    text-align: center;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 200;
    width: auto;
    min-width: 280px;
    max-width: 90vw;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.processing p {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #ffffff;
}

.processing small {
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
}

.result-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: url('../img/background.png') center center / cover no-repeat;
    padding: 60px 20px 20px;
    text-align: center;
    z-index: 300;
    overflow-y: auto;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.result-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
    padding: 0 20px;
}

.close-result-btn {
    width: 48px;
    height: 48px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #ffffff;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.close-result-btn:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 1);
    background: rgba(255, 255, 255, 0.2);
}

.result-section h3 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 30px;
    color: #ffffff;
    letter-spacing: -0.003em;
}

.result-image {
    width: 100%;
    max-width: 350px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    margin: 0 auto 30px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.frame-style-badge {
    display: inline-block;
    background: #007aff;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 15px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: -0.022em;
    margin-top: 12px;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.2);
}

.download-button {
    border: 2px solid rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 17px;
    font-weight: 500;
    letter-spacing: -0.022em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.download-button:hover {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 1);
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.download-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.2);
}

.error {
    background: #ff3b30;
    color: #ffffff;
    padding: 16px;
    border-radius: 12px;
    margin: 16px 0;
    text-align: center;
    font-weight: 500;
    font-size: 17px;
    border: 0.5px solid #ff3b30;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.2);
}

.hidden {
    display: none;
}

/* Apple-style animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.camera-section,
.result-section {
    animation: fadeInUp 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.processing {
    animation: fadeInCenter 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes fadeInCenter {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Responsive adjustments - Apple 8-point grid */
@media (max-width: 480px) {
    .static-title h1 {
        font-size: 36px;
    }
    
    .static-title {
        padding: 20px 20px;
    }
    
    .capture-button {
        width: 72px;
        height: 72px;
    }
    
    .camera-controls {
        height: 96px;
    }
}

@media (max-width: 360px) {
    .static-title {
        padding: 20px 20px;
    }
    
    .static-title h1 {
        font-size: 40px;
    }
    
    .capture-button {
        width: 64px;
        height: 64px;
    }
    
    .camera-controls {
        height: 88px;
    }
}

@media (min-width: 768px) {
    .static-title h1 {
        font-size: 80px;
    }
    
    .static-title {
        padding: 48px 24px 8px;
    }
    
    .capture-button {
        width: 88px;
        height: 88px;
    }
    
    .camera-controls {
        height: 112px;
    }
}

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, #f5f5f7 25%, #e5e5e7 50%, #f5f5f7 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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