/* Modern App Styling */
:root {
    --primary-color: #007AFF; /* iOS Blue */
    --background-color: #F2F2F7; /* iOS System Gray 6 */
    --card-background: #FFFFFF;
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --separator: #C6C6C8;
    --safe-area-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body { 
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
    background-color: var(--background-color); 
    color: var(--text-primary); 
    height: 100vh; 
    width: 100vw;
    overflow: hidden; 
    margin: 0;
    padding: 0;
}

/* Glassmorphism Header */
header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px 20px; 
    border-bottom: 0.5px solid rgba(0,0,0,0.1);
    z-index: 100; 
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

header h1 { 
    font-size: 17px; 
    font-weight: 600; 
    margin: 0; 
    letter-spacing: -0.5px;
}

/* Pill Button */
.toggle-btn {
    background: var(--primary-color); 
    color: white; 
    border: none; 
    padding: 8px 18px;
    border-radius: 100px; 
    font-size: 14px; 
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s, background-color 0.2s;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.2);
}

.toggle-btn:active {
    transform: scale(0.96);
    opacity: 0.9;
}

/* Main Container */
.app-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

#body-container {
    flex: 1;
    position: relative;
    display: flex; 
    justify-content: center; 
    align-items: center;
    padding: 80px 20px 40px; /* Top padding for fixed header */
    overflow: hidden;
}

/* View Switching with Animation */
.body-view {
    display: none; 
    width: 100%; 
    height: 100%;
    max-width: 450px;
    animation: fadeIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.body-view.active {
    display: block; 
}

/* Muscles */
.muscle {
    cursor: pointer;
    transition: all 0.2s ease;
    /* Ensure muscles have a transparent fill by default so they catch clicks but don't obscure the drawing */
    fill-opacity: 0; 
}

.muscle:active { 
    fill: var(--primary-color) !important; 
    fill-opacity: 0.3 !important;
}

.muscle.selected { 
    fill: var(--primary-color) !important; 
    fill-opacity: 0.5 !important;
    stroke: var(--primary-color);
    stroke-width: 1px;
}

/* Bottom Sheet Modal */
.modal {
    display: none; 
    position: fixed; 
    top: 0;
    left: 0; 
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4); 
    z-index: 200;
    backdrop-filter: blur(4px); /* Blurs the background content */
    align-items: flex-end; 
    opacity: 0;
    transition: opacity 0.3s;
}

.modal.visible {
    display: flex; 
    opacity: 1;
}

.modal-content {
    background: var(--card-background); 
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 30px 24px 40px; 
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1); /* iOS spring curve */
    position: relative;
    padding-bottom: calc(30px + var(--safe-area-bottom));
}

.modal.visible .modal-content {
    transform: translateY(0);
}

/* Drag Handle Indicator */
.modal-content::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 5px;
    background: #E5E5EA;
    border-radius: 3px;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 30px;
    height: 30px;
    background: #F2F2F7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px; 
    color: var(--text-secondary);
    cursor: pointer; 
    border: none;
    transition: background 0.2s;
}

.close-btn:hover { background: #E5E5EA; }

/* Content Styling */
#muscle-name { 
    color: var(--text-primary); 
    font-size: 28px;
    font-weight: 700;
    margin: 10px 0 8px; 
    letter-spacing: -0.5px;
}

#muscle-desc {
    color: var(--text-secondary);
    font-size: 17px;
    line-height: 1.4;
    margin-bottom: 24px;
}

#stretch-guide { 
    background: #F2F2F7;
    border-radius: 16px;
    padding: 20px;
    margin-top: 10px;
}

#stretch-guide h3 { 
    font-size: 13px; 
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 0 0 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

#stretch-name {
    color: var(--primary-color);
    font-weight: 600;
}

#stretch-instructions {
    margin-top: 8px;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
}