* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a1a;
    color: #fff;
    overflow-x: hidden;
}

h1 {
    text-align: center;
    padding: 20px;
    color: #667eea;
}

#container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    gap: 20px;
    flex-wrap: wrap;
}

#video-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#canvas {
    border: 2px solid #667eea;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    max-width: 100%;
    height: auto;
    background: #000;
}

#controls {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

button {
    padding: 10px 20px;
    font-size: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#resetBtn { background: #e74c3c; color: white; }
#resetBtn:hover { background: #c0392b; }

#clearAllBtn { background: #95a5a6; color: white; }
#clearAllBtn:hover { background: #7f8c8d; }

#downloadBtn { background: #27ae60; color: white; }
#downloadBtn:hover { background: #229954; }
#downloadBtn:disabled { background: #555; cursor: not-allowed; }

.toggle-group {
    display: flex;
    background: #333;
    border-radius: 6px;
    overflow: hidden;
}

.toggle-btn {
    padding: 10px 24px;
    font-size: 14px;
    background: #333;
    color: #888;
    border: none;
    border-radius: 0;
}

.toggle-btn.active {
    background: #667eea;
    color: white;
}

.toggle-btn:hover:not(.active) {
    background: #444;
}

#status {
    margin-top: 10px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
}

.loading { color: #667eea; }
.ready { color: #2ecc71; }

#video { display: none; }

.keyboard-hint {
    font-size: 11px;
    color: #666;
    margin-top: 8px;
}

/* Measurements Panel */
#measurements-panel {
    background: #252525;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 20px;
    min-width: 420px;
    max-width: 500px;
}

#measurements-panel h2 {
    color: #667eea;
    font-size: 18px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #444;
}

/* Table Styles */
.measurement-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.measurement-table th,
.measurement-table td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid #333;
}

.measurement-table th {
    background: #333;
    color: #888;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.measurement-table th:first-child {
    text-align: left;
    padding-left: 12px;
}

.measurement-table td:first-child {
    text-align: left;
    padding-left: 12px;
    color: #ccc;
    font-weight: 500;
}

.measurement-table td {
    font-size: 14px;
    font-weight: 600;
}

.measurement-table .value-left {
    color: #3498db;
}

.measurement-table .value-right {
    color: #e67e22;
}

.measurement-table .value-none {
    color: #555;
}

.measurement-table tr:last-child td {
    border-bottom: none;
}

.measurement-table .tracking-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 6px;
    animation: pulse 1s infinite;
}

.measurement-table .tracking-left {
    background: #3498db;
}

.measurement-table .tracking-right {
    background: #e67e22;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.section-header {
    color: #888;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 20px 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid #333;
}

.quality-bar {
    margin-top: 15px;
    padding: 10px;
    background: #333;
    border-radius: 4px;
}

.quality-bar .label {
    font-size: 12px;
    color: #888;
    margin-bottom: 5px;
}

.quality-track {
    height: 8px;
    background: #444;
    border-radius: 4px;
    overflow: hidden;
}

.quality-fill {
    height: 100%;
    background: #2ecc71;
    transition: width 0.3s ease;
}

.quality-fill.warning { background: #f39c12; }
.quality-fill.poor { background: #e74c3c; }

.status-message {
    margin-top: 10px;
    padding: 8px;
    background: #3a3a2a;
    border-radius: 4px;
    font-size: 12px;
    color: #f39c12;
    display: none;
}

.status-message.visible { display: block; }

.legend {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    padding: 10px;
    background: #2a2a2a;
    border-radius: 4px;
    font-size: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot.left { background: #3498db; }
.legend-dot.right { background: #e67e22; }