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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: #f8f9fa;
    color: #333;
    line-height: 1.5;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.workout-header {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.back-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #007bff;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
}

.back-btn:hover {
    background: #f8f9fa;
}

.workout-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.workout-timer {
    font-size: 16px;
    font-weight: 500;
    color: #666;
}

/* Video Section */
.video-section {
    background: #000;
    position: relative;
}

.video-container {
    position: relative;
    width: 100%;
    max-height: 300px;
    overflow: hidden;
}

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

#poseCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.toggle-video-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    z-index: 10;
}

/* Form Feedback Overlay */
.form-feedback-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.8) 0%,
        rgba(0, 0, 0, 0.3) 40%,
        rgba(0, 0, 0, 0.1) 60%,
        rgba(0, 0, 0, 0.7) 100%
    );
    color: white;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
    z-index: 5;
}

.feedback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.feedback-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.detection-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #dc3545;
    transition: background-color 0.3s ease;
}

.status-dot.detecting {
    background: #28a745;
    animation: pulse 2s infinite;
}

.status-dot.partial {
    background: #ffc107;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

#statusText {
    font-size: 14px;
    font-weight: 500;
}

.feedback-content {
    margin-top: auto;
}

.form-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 16px;
    background: rgba(0, 0, 0, 0.6);
    padding: 12px;
    border-radius: 8px;
}

.metric {
    text-align: center;
}

.metric-label {
    display: block;
    font-size: 12px;
    color: #ccc;
    margin-bottom: 4px;
}

.metric-value {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.form-guidance {
    background: rgba(0, 123, 255, 0.8);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}

.form-guidance p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

.form-guidance.warning {
    background: rgba(255, 193, 7, 0.8);
    color: #000;
}

.form-guidance.success {
    background: rgba(40, 167, 69, 0.8);
}

/* Main Content */
.workout-content {
    flex: 1;
    padding: 20px;
}

/* Exercise Selection Screen */
.exercise-selection-screen h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 24px;
    text-align: center;
    color: #333;
}

.exercise-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 32px;
}

.exercise-card {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.exercise-card:hover {
    border-color: #007bff;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.1);
}

.exercise-card.selected {
    border-color: #007bff;
    background: #f0f8ff;
}

.exercise-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.exercise-card h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.exercise-card p {
    color: #666;
    font-size: 14px;
}

.start-workout-btn {
    width: 100%;
    background: #007bff;
    color: white;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.start-workout-btn:hover:not(:disabled) {
    background: #0056b3;
}

.start-workout-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Workout Session */
.workout-session {
    max-width: 600px;
    margin: 0 auto;
}

.current-exercise {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.exercise-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.exercise-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.finish-exercise-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

/* Sets Display */
.sets-container {
    margin-bottom: 32px;
}

.sets-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    font-size: 14px;
    color: #666;
}

.sets-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.set-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    padding: 12px 0;
    align-items: center;
    border-bottom: 1px solid #f8f9fa;
}

.set-number {
    font-weight: 600;
    color: #333;
}

.set-reps {
    font-size: 18px;
    font-weight: 600;
    color: #007bff;
}

.set-type {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
}

/* Current Set */
.current-set {
    border-top: 2px solid #f8f9fa;
    padding-top: 24px;
}

.set-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.set-info h3 {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.rep-display {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.rep-count {
    font-size: 36px;
    font-weight: 700;
    color: #007bff;
}

.rep-label {
    font-size: 16px;
    color: #666;
}

.set-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Buttons */
.primary-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
    min-width: 120px;
    transition: background 0.2s ease;
}

.primary-btn:hover {
    background: #0056b3;
}

.secondary-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
    min-width: 120px;
    transition: background 0.2s ease;
}

.secondary-btn:hover {
    background: #1e7e34;
}

.manual-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.manual-btn:hover {
    background: #545b62;
}

/* Exercise Queue */
.exercise-queue {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
}

.exercise-queue h4 {
    font-size: 16px;
    font-weight: 600;
    color: #666;
    margin-bottom: 16px;
}

.next-exercises-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.next-exercise-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 8px;
}

.next-exercise-icon {
    font-size: 24px;
}

.next-exercise-name {
    font-weight: 500;
    color: #333;
}

/* Workout Summary */
.workout-summary {
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.workout-summary h2 {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin-bottom: 32px;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #007bff;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: #666;
    text-transform: uppercase;
    font-weight: 500;
}

.exercise-summary {
    margin-bottom: 32px;
}

.exercise-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid #f8f9fa;
}

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

.exercise-summary-name {
    font-weight: 600;
    color: #333;
}

.exercise-summary-stats {
    font-size: 14px;
    color: #666;
}

/* Status Bar */
.status-bar {
    background: #fff;
    border-top: 1px solid #e9ecef;
    padding: 16px 20px;
    text-align: center;
}

.status-bar p {
    font-size: 14px;
    color: #666;
}

/* Rest Timer Modal */
.rest-timer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.rest-timer-content {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    max-width: 300px;
    width: 90%;
}

.rest-timer-content h3 {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 24px;
}

.timer-display {
    margin-bottom: 32px;
}

.timer-display span {
    font-size: 48px;
    font-weight: 700;
    color: #007bff;
}

.timer-controls {
    display: flex;
    gap: 12px;
}

.timer-controls button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

#skipRestBtn {
    background: #6c757d;
    color: white;
}

#addTimeBtn {
    background: #007bff;
    color: white;
}

/* Debug Panel */
.debug-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.debug-toggle {
    background: #333;
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 25px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.debug-content {
    position: absolute;
    bottom: 60px;
    right: 0;
    background: #333;
    color: white;
    padding: 16px;
    border-radius: 8px;
    width: 300px;
    font-family: monospace;
    font-size: 12px;
}

.debug-content h4 {
    margin-bottom: 8px;
    color: #fff;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .workout-content {
        padding: 16px;
    }
    
    .exercise-grid {
        gap: 12px;
    }
    
    .exercise-card {
        padding: 20px;
    }
    
    .current-exercise {
        padding: 20px;
    }
    
    .set-controls {
        flex-direction: column;
    }
    
    .primary-btn,
    .secondary-btn {
        min-width: unset;
    }
    
    .summary-stats {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .video-container {
        max-height: 250px;
    }
}