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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #10b981;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;
    --success: #22c55e;
    --warning: #f59e0b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2.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;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Upload Area */
.upload-section {
    margin-bottom: 2rem;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--surface);
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--surface-light);
}

.upload-area.dragover {
    border-color: var(--secondary);
    background: rgba(16, 185, 129, 0.1);
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.upload-area p {
    color: var(--text);
    margin-bottom: 0.5rem;
}

.upload-area .hint {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Settings Section */
.settings-section {
    background: var(--surface);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.settings-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-item label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.setting-item select {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.setting-item select:hover {
    border-color: var(--primary);
}

.setting-item select:focus {
    outline: none;
    border-color: var(--primary);
}

.setting-item input[type="text"] {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    color: var(--text);
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.setting-item input[type="text"]:hover {
    border-color: var(--primary);
}

.setting-item input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.setting-item input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--background);
    cursor: pointer;
    -webkit-appearance: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: background 0.2s ease;
}

.setting-item input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-dark);
}

.model-status {
    color: var(--secondary);
    font-size: 0.875rem;
    text-align: center;
}

.model-status.loading {
    color: var(--warning);
}

.model-status.error {
    color: #ef4444;
}

/* Demo Section */
.demo-section {
    text-align: center;
    margin-bottom: 2rem;
}

.demo-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.demo-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.demo-btn {
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.demo-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* Result Section */
.result-section {
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.result-header h2 {
    font-size: 1.5rem;
}

.person-count {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
}

.count-number {
    font-size: 2rem;
    font-weight: 700;
}

.count-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* Image Container */
.image-container {
    position: relative;
    margin-bottom: 1.5rem;
    border-radius: 12px;
    overflow: hidden;
    background: var(--background);
}

#outputCanvas {
    width: 100%;
    height: auto;
    display: block;
}

/* Stats */
.stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    gap: 0.5rem;
}

.stat-label {
    color: var(--text-muted);
}

.stat-value {
    font-weight: 600;
    color: var(--secondary);
}

/* Detection List */
.detection-list {
    max-height: 200px;
    overflow-y: auto;
}

.detection-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.detection-item:last-child {
    border-bottom: none;
}

.detection-id {
    color: var(--text-muted);
}

.detection-confidence {
    font-weight: 600;
}

.detection-confidence.high {
    color: var(--success);
}

.detection-confidence.medium {
    color: var(--warning);
}

.detection-confidence.low {
    color: #ef4444;
}

/* Loading Section */
.loading-section {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--surface-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Footer */
footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.footer-content {
    text-align: center;
}

.footer-content h3 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

.footer-content p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.footer-content pre {
    background: var(--surface);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.footer-content code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    color: var(--secondary);
}

.github-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.github-link:hover {
    background: var(--primary);
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .result-header {
        flex-direction: column;
        text-align: center;
    }

    .stats {
        flex-direction: column;
        gap: 0.5rem;
    }
}
