:root {
    --bg-dark: #080c14;
    --card-bg: rgba(14, 21, 37, 0.75);
    --border: rgba(255, 255, 255, 0.08);
    --accent: #38bdf8;
    --green: #10b981;
    --amber: #f59e0b;
    --rose: #f43f5e;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

.ambient-glow {
    position: fixed;
    top: -10%;
    left: 25%;
    width: 50vw;
    height: 40vh;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.1) 0%, rgba(16, 185, 129, 0.04) 60%, transparent 80%);
    filter: blur(80px);
    pointer-events: none;
    z-index: 0;
}

header {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 36px;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    background: rgba(8, 12, 20, 0.85);
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #ffffff 40%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-top: 2px;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.badge {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-accent {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border-color: rgba(99, 102, 241, 0.3);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mode-selector {
    display: flex;
    background: rgba(255, 255, 255, 0.04);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border);
    gap: 4px;
}

.mode-btn {
    padding: 6px 14px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn.active {
    background: rgba(56, 189, 248, 0.2);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.4);
}

.btn {
    padding: 8px 18px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, #0284c7, #2563eb);
    color: #fff;
    box-shadow: 0 0 15px rgba(2, 132, 199, 0.4);
}

.btn-primary:hover {
    box-shadow: 0 0 25px rgba(2, 132, 199, 0.7);
    transform: translateY(-1px);
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
}

.btn-text:hover { color: var(--text-primary); }

.app-layout {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 36px;
    flex: 1;
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 24px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    backdrop-filter: blur(16px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
}

/* Video Canvas Section */
.video-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    min-height: 480px;
    background: #04060a;
}

#outputCanvas {
    width: 100%;
    height: auto;
    max-height: 540px;
    border-radius: 8px;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror selfie view */
}

.camera-prompt {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 420px;
    padding: 24px;
    gap: 12px;
}

.prompt-icon {
    font-size: 3rem;
    filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.4));
}

.camera-prompt p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.slouch-alert {
    position: absolute;
    top: 24px;
    background: rgba(244, 63, 94, 0.95);
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 0 30px rgba(244, 63, 94, 0.8);
    animation: alertPulse 0.8s infinite alternate ease-in-out;
}

@keyframes alertPulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.04); }
}

.rep-banner {
    position: absolute;
    bottom: 30px;
    background: rgba(16, 185, 129, 0.95);
    color: #fff;
    padding: 10px 24px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.7);
    animation: repPop 0.5s ease-out;
}

@keyframes repPop {
    0% { transform: scale(0.6); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.hidden { display: none !important; }

/* Right Telemetry Column */
.telemetry-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.status-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
}

.status-good {
    background: rgba(16, 185, 129, 0.15);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-warn {
    background: rgba(245, 158, 11, 0.15);
    color: var(--amber);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-bad {
    background: rgba(244, 63, 94, 0.15);
    color: var(--rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.score-display {
    display: flex;
    align-items: center;
    gap: 20px;
}

.score-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--green);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

#scoreVal {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
}

.score-unit {
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.score-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.score-desc {
    font-size: 0.85rem;
    line-height: 1.4;
    color: #cbd5e1;
}

.angle-meters {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.meter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.meter-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    font-weight: 600;
}

.angle-val {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent);
}

.meter-bar-track {
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    overflow: hidden;
}

.meter-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: 4px;
    transition: width 0.2s ease, background-color 0.3s;
}

.meter-guide {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 8px;
    text-align: center;
}

.stat-number {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.stat-title {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-accent { color: var(--accent); }

.toggle-control {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
    cursor: pointer;
    user-select: none;
}

.toggle-control input { display: none; }

.toggle-slider {
    width: 36px;
    height: 20px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    position: relative;
    transition: 0.3s;
}

.toggle-slider:before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    top: 3px;
    left: 3px;
    transition: 0.3s;
}

.toggle-control input:checked + .toggle-slider {
    background: var(--green);
}

.toggle-control input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 16px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}

footer a {
    color: var(--accent);
    text-decoration: none;
}
