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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
    background-color: #2C2E3B;
    color: #ffffff;
    min-height: 100vh;
    padding: 16px 16px 32px 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
    touch-action: manipulation;
}

h1 {
    text-align: center;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: bold;
    color: #93c5fd;
    margin-bottom: 32px;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.container {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 0 16px;
}

/* Tab Navigation */
.tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 4px;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: fit-content;
    touch-action: manipulation;
}

.tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.tab.active {
    background: #3b82f6;
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}

.video-container {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    margin-bottom: 24px;
    aspect-ratio: 16/9;
    max-height: 70vh;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.2);
}

video, canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 12px;
    object-fit: cover;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
}

.controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 24px;
}

button {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    min-height: 44px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

button.camera-switch {
    background: #1e40af;
    position: relative;
}

button.camera-switch:hover {
    background: #1e3a8a;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.3);
}

button:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

button:disabled {
    background: #6b7280;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.info {
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    text-align: center;
    font-size: 14px;
    line-height: 1.6;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.info .detected {
    color: #3b82f6;
    font-weight: 600;
}

.results-container {
    margin-top: 24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detected-objects, .detected-texts {
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.detected-objects h3,
.detected-texts h3 {
    margin: 0 0 16px 0;
    color: #93c5fd;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

.object-list,
.text-list {
    max-height: 150px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 12px;
}

.object-item,
.text-item {
    background: rgba(59, 130, 246, 0.2);
    color: white;
    padding: 8px 12px;
    margin: 4px 0;
    border-radius: 6px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.text-item {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.3);
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.4;
}

.object-name {
    font-weight: 600;
}

.object-confidence {
    font-size: 12px;
    opacity: 0.8;
    color: #93c5fd;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    color: #9ca3af;
    font-weight: 500;
}

/* Feature-specific styles */
.options {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    justify-content: center;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 44px;
    transition: all 0.3s ease;
}

.option-group:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(59, 130, 246, 0.3);
}

.option-group label {
    font-size: clamp(12px, 2.5vw, 14px);
    cursor: pointer;
    user-select: none;
}

input[type="checkbox"] {
    width: clamp(16px, 4vw, 18px);
    height: clamp(16px, 4vw, 18px);
    cursor: pointer;
    touch-action: manipulation;
}

select {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: clamp(6px, 1.5vw, 8px) clamp(8px, 2vw, 12px);
    border-radius: 6px;
    font-size: clamp(12px, 2.5vw, 14px);
    cursor: pointer;
    min-height: 44px;
    touch-action: manipulation;
}

select option {
    background: #2C2E3B;
}

.fps-counter {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.8);
    color: #3b82f6;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-family: monospace;
    font-weight: 600;
    pointer-events: none;
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .tabs {
        justify-content: flex-start;
        padding-bottom: 5px;
    }

    .tab {
        flex: 1;
        min-width: calc(33.333% - 5px);
        text-align: center;
    }

    .options {
        flex-direction: column;
        align-items: stretch;
    }

    .option-group {
        justify-content: space-between;
        width: 100%;
    }

    .controls {
        gap: 8px;
    }

    button {
        flex: 1;
        min-width: calc(50% - 4px);
    }
    
    .results-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }

    .container {
        border-radius: 12px;
    }

    .video-container {
        max-height: 60vh;
    }

    .tab {
        font-size: 11px;
        padding: 8px 12px;
    }

    h1 {
        font-size: 1.25rem;
        margin-bottom: 10px;
    }
}

/* Touch and Gesture Support */
@media (hover: none) and (pointer: coarse) {
    .tab:hover {
        background: rgba(255, 255, 255, 0.1);
        transform: none;
    }

    button:hover {
        background: #4CAF50;
        transform: none;
        box-shadow: none;
    }
}

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

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

.animate-fadeIn {
    animation: fadeIn 0.3s ease-in-out;
}

.animate-slideIn {
    animation: slideIn 0.4s ease-out;
}

/* Footer */
footer {
    margin-top: 48px;
    padding: 24px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

footer a {
    color: #3b82f6;
    text-decoration: none;
    transition: color 0.3s ease;
    font-weight: 500;
}

footer a:hover {
    color: #2563eb;
}