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

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: #f5f5f5;
    color: #212121;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
}

.screen.active {
    display: flex;
}

.app-header {
    background: #673AB7;
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-header h1 {
    font-size: 20px;
    font-weight: 500;
    margin: 0;
    flex: 1;
}

.back-button {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0 16px 0 0;
    margin: 0;
}

.back-button:hover {
    opacity: 0.8;
}

.content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.welcome-section {
    text-align: center;
    padding: 60px 20px;
}

.icon-large {
    font-size: 80px;
    margin-bottom: 20px;
}

.welcome-section h2 {
    font-size: 24px;
    font-weight: 500;
    margin-bottom: 12px;
    color: #212121;
}

.welcome-section p {
    font-size: 16px;
    color: #757575;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 300px;
    margin: 40px auto;
}

.primary-button {
    background: #673AB7;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s;
}

.primary-button:hover:not(:disabled) {
    background: #5E35B1;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.primary-button:disabled {
    background: #BDBDBD;
    cursor: not-allowed;
    box-shadow: none;
}

.button-icon {
    font-size: 20px;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
    color: white;
}

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

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

.loading-content p {
    font-size: 16px;
}

.image-preview {
    margin-bottom: 20px;
    background: #f5f5f5;
    border-radius: 12px;
    overflow: hidden;
}

.image-preview canvas {
    display: block;
    width: 100%;
    height: auto;
}

.detected-items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.detected-item {
    background: white;
    border: 2px solid #E0E0E0;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 16px;
}

.detected-item:hover {
    border-color: #673AB7;
}

.detected-item.selected {
    border-color: #673AB7;
    background: #F3E5F5;
}

.item-preview {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

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

.item-details {
    flex: 1;
}

.item-label {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
}

.item-confidence {
    font-size: 14px;
    color: #757575;
}

.item-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid #9E9E9E;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.detected-item.selected .item-checkbox {
    background: #673AB7;
    border-color: #673AB7;
    color: white;
}

.shopping-results-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.item-results-section {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.item-results-header {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #E0E0E0;
}

.shopping-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.shopping-result-card {
    background: white;
    border: 1px solid #E0E0E0;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.shopping-result-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transform: translateY(-2px);
}

.shopping-result-card.selected {
    border: 2px solid #673AB7;
}

.shopping-result-card.broken-link {
    transition: opacity 0.5s ease;
    filter: grayscale(100%);
}

.result-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #f5f5f5;
}

.result-details {
    padding: 12px;
}

.result-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.result-price {
    font-size: 14px;
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 4px;
}

.result-source {
    font-size: 12px;
    color: #757575;
}

.list-header {
    text-align: center;
    padding: 30px 20px;
    background: #f5f5f5;
    border-radius: 12px;
    margin-bottom: 20px;
}

.icon-cart {
    font-size: 48px;
    margin-bottom: 12px;
}

.list-header h2 {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 8px;
}

.list-header p {
    font-size: 14px;
    color: #757575;
}

.final-link-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.final-link-card.opened {
    background: #E8F5E9;
    border: 2px solid #4CAF50;
}

.link-content {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.link-thumbnail {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.link-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.link-info {
    flex: 1;
}

.link-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.link-price {
    font-size: 16px;
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 4px;
}

.link-source {
    font-size: 14px;
    color: #757575;
}

.link-button {
    width: 100%;
    background: #673AB7;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.final-link-card.opened .link-button {
    background: #4CAF50;
}

.link-button:hover {
    opacity: 0.9;
}

.list-footer {
    text-align: center;
    padding: 16px;
    background: #f5f5f5;
    border-radius: 12px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.info-icon {
    font-size: 20px;
}

.list-footer span {
    font-size: 14px;
    color: #757575;
}

@media (max-width: 600px) {
    .app-container {
        max-width: 100%;
    }

    .shopping-results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
