:root {
    --bg-color: #ffffff;
    --text-main: #000000;
    --text-secondary: #666666;
    --border-color: #e5e5e5;
    --accent-color: #000000;
    --surface-color: #ffffff;
    --error-color: #ef4444;
    --success-color: #16a34a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* Card Styles (Shared) */
.card {
    background: var(--surface-color);
    padding: 3rem;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
}

.icon-wrapper {
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 2rem;
}

/* Form Styles */
.input-group {
    margin-bottom: 1rem;
    text-align: left;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus {
    border-color: var(--accent-color);
}

.checkbox-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 2rem;
    cursor: pointer;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.terms-check {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem;
}

.checkbox-container:hover {
    border-color: var(--border-color);
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-color);
    cursor: pointer;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

button {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

button:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

button:not(:disabled):hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* GitHub Button */
.github-btn {
    background: #24292e;
    color: white;
    margin-bottom: 1rem;
}

.github-btn:hover {
    background: #1b1f23;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 1rem 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.divider::before {
    margin-right: .5em;
}

.divider::after {
    margin-left: .5em;
}

/* Selection Screen */
.selection-header {
    position: absolute;
    top: 20px;
    right: 20px;
}

.logout-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    font-size: 0.85rem;
    width: auto;
}

.logout-btn:hover {
    background: #f9fafb;
    color: var(--error-color);
    border-color: var(--error-color);
}

.selection-container {
    text-align: center;
    width: 90%;
    max-width: 800px;
}

.cards-row {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.mode-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    width: 280px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.mode-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.mode-card .icon-box {
    width: 64px;
    height: 64px;
    background: #f9fafb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: var(--text-main);
}

.mode-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.mode-card p {
    font-size: 0.85rem;
    margin-bottom: 0;
}

/* Analysis Screen */
.analysis-container {
    display: flex;
    gap: 40px;
    width: 90%;
    max-width: 900px;
    height: 80vh;
}

.upload-section {
    flex: 1;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-box {
    width: 100%;
    height: 300px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s;
}

.upload-box:hover {
    border-color: var(--accent-color);
}

.upload-box input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
}

.preview-image {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f9fafb;
    display: none;
    z-index: 1;
}

.analysis-canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
    /* Same as image, but we will draw on top */
    pointer-events: none;
}

.result-section {
    flex: 1;
    background: #f9fafb;
    border-radius: 16px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--accent-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    background: white;
    flex-shrink: 0;
}

.score-circle span {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.score-circle small {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.ai-feedback {
    width: 100%;
    text-align: left;
}

.ai-feedback h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.ai-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    margin-bottom: 1.5rem;
}

.ai-breakdown {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.breakdown-item {
    background: white;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.breakdown-item strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-main);
}

.back-btn {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: auto;
    padding: 10px 20px;
    background: white;
    color: black;
    border: 1px solid var(--border-color);
    z-index: 100;
}

.back-btn-text {
    background: transparent;
    color: var(--text-secondary);
    margin-top: 1rem;
    width: auto;
}

.back-btn-text:hover {
    background: transparent;
    color: var(--text-main);
    text-decoration: underline;
}

/* App Screen */
.video-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #f3f4f6;
    display: flex;
    justify-content: center;
    align-items: center;
}

.input_video,
.output_canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 20;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #e5e5e5;
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.stats-panel {
    position: absolute;
    top: 24px;
    left: 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    min-width: 240px;
    z-index: 10;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.stat-item .label {
    color: var(--text-secondary);
}

.stat-item .value {
    font-family: 'Inter', monospace;
    font-weight: 600;
    color: var(--text-main);
}

/* Posture Card */
.posture-card {
    background: #f9fafb;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.posture-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.posture-status {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--success-color);
}

.posture-status.bad {
    color: var(--error-color);
}

.posture-bar {
    height: 4px;
    background: #e5e5e5;
    border-radius: 2px;
    overflow: hidden;
}

.posture-bar .fill {
    height: 100%;
    width: 100%;
    background: var(--success-color);
    transition: width 0.3s, background-color 0.3s;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--success-color);
    background: #dcfce7;
    padding: 4px 10px;
    border-radius: 99px;
    width: fit-content;
}

.status-indicator .dot {
    width: 6px;
    height: 6px;
    background-color: var(--success-color);
    border-radius: 50%;
}

@media (max-width: 768px) {
    .card {
        padding: 2rem;
    }

    .stats-panel {
        top: auto;
        bottom: 24px;
        left: 24px;
        right: 24px;
        width: auto;
    }

    .analysis-container {
        flex-direction: column;
        height: auto;
        padding: 20px 0;
    }
}