/* === eFitApp MVP Styles === */

/* --- Global Variables & Resets --- */
:root {
    --primary-color: #007bff;
    --primary-color-hover: #0056b3;
    --success-color: #28a745;
    --success-color-hover: #1e7e34;
    --danger-color: #dc3545;
    --danger-color-hover: #c82333;
    --secondary-color: #6c757d;
    --secondary-color-hover: #545b62;
    --info-color: #17a2b8;
    --info-color-hover: #117a8b;
    --warning-color: #ffc107;
    --warning-color-hover: #e0a800;

    /* Default Dark Theme Colors */
    --background-color: #121212;
    --surface-color: #1e1e1e; /* Cards, modals, nav */
    --on-surface-color: #2a2a2a; /* Inputs, interactive elements on surface */
    --text-color: #e0e0e0;
    --text-secondary-color: #a0a0a0;
    --border-color: #333333;

    --spacing-unit: 8px;
    --border-radius: 8px;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    height: 100%;
    overflow: hidden;
}

body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#app-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

/* --- Screen Management --- */
.screen {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: calc(var(--spacing-unit) * 2);
    padding-bottom: calc(60px + var(--spacing-unit) * 3); /* Main nav height + buffer */
    min-height: 0;
    background-color: var(--background-color);
    overflow-y: auto;
    position: relative;
}

.screen-header {
    flex-shrink: 0;
    padding-bottom: calc(var(--spacing-unit) * 2);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--spacing-unit);
    text-align: center;
}
.screen-header .header-with-back { display: flex; align-items: center; justify-content: center; position: relative; width: 100%; }
.screen-header .header-with-back h1 { flex-grow: 1; text-align: center; margin: 0; font-size: 1.5rem; }
.screen-header > h1 { margin: 0 0 var(--spacing-unit) 0; font-size: 1.8rem; color: var(--text-color); }
.screen-header p { margin: 0; color: var(--text-secondary-color); font-size: 0.9rem; }

.screen-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.screen-footer.sticky { /* For footers like on Plan Review */
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--background-color);
    border-top: 1px solid var(--border-color);
    padding: var(--spacing-unit) calc(var(--spacing-unit)*2);
    z-index: 100;
    flex-shrink: 0;
}
/* Content padding for screens with their own sticky footers */
#plan-review-screen .screen-content {
    padding-bottom: calc(50px + var(--spacing-unit) * 2); /* Approx footer height + buffer */
}

.list-placeholder, .no-sets-placeholder {
    text-align: center; color: var(--text-secondary-color); padding: var(--spacing-unit);
    font-style: italic; font-size: 0.9rem;
}
.input-hint { font-size: 0.8rem; color: var(--text-secondary-color); margin-top: calc(var(--spacing-unit) / 2); }

/* Center content for specific screens */
#onboarding-screen .screen-content,
#edit-plan-screen .screen-content,
#home-choice-screen .screen-content {
    justify-content: center; align-items: center; text-align: center;
}
#onboarding-screen .form-group, #onboarding-screen .btn,
#edit-plan-screen .form-group, #edit-plan-screen .form-actions,
#home-choice-screen .form-actions {
    width: 100%; max-width: 350px; text-align: left;
}
#onboarding-screen .btn, #home-choice-screen .form-actions .btn { text-align: center; }

/* --- Splash Screen --- */
#splash-screen { display: none; justify-content: center; align-items: center; background-color: #ffffff !important; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 9999; padding: 0 !important; opacity: 0; transition: opacity 0.5s ease-in-out; }
#splash-screen.visible { display: flex !important; opacity: 0; }
#splash-screen.perform-fade-in { animation: fadeInAnimation 0.5s ease-in-out forwards; }
#splash-screen.perform-fade-out { animation: fadeOutAnimation 0.5s ease-in-out forwards; }
.splash-content { text-align: center; }
#splash-logo { max-width: 60vw; max-height: 60vh; width: auto; height: auto; display: block; margin: 0 auto; }
@keyframes fadeInAnimation { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes fadeOutAnimation { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0.95); } }

/* --- Common UI Elements: Buttons, Forms --- */
.btn { display: inline-block; padding: calc(var(--spacing-unit) * 1.25) calc(var(--spacing-unit) * 2.5); font-size: 1rem; font-weight: 500; text-align: center; text-decoration: none; color: #fff; background-color: var(--primary-color); border: 1px solid var(--primary-color); border-radius: var(--border-radius); cursor: pointer; transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.1s ease; margin: calc(var(--spacing-unit)/2) 0; width: 100%; }
.btn:active { transform: scale(0.98); }
.btn-primary { background-color: var(--primary-color); border-color: var(--primary-color); } .btn-primary:hover { background-color: var(--primary-color-hover); border-color: var(--primary-color-hover); }
.btn-success { background-color: var(--success-color); border-color: var(--success-color); } .btn-success:hover { background-color: var(--success-color-hover); border-color: var(--success-color-hover); }
.btn-danger { background-color: var(--danger-color); border-color: var(--danger-color); } .btn-danger:hover { background-color: var(--danger-color-hover); border-color: var(--danger-color-hover); }
.btn-secondary { background-color: var(--secondary-color); border-color: var(--secondary-color); } .btn-secondary:hover { background-color: var(--secondary-color-hover); border-color: var(--secondary-color-hover); }
.btn-info { background-color: var(--info-color); border-color: var(--info-color); } .btn-info:hover { background-color: var(--info-color-hover); border-color: var(--info-color-hover); }
.btn-warning { background-color: var(--warning-color); border-color: var(--warning-color); color: #000; }
.btn-warning:hover { background-color: var(--warning-color-hover); border-color: var(--warning-color-hover); }
.btn-outline { background-color: transparent; border: 1px solid var(--primary-color); color: var(--primary-color); } .btn-outline:hover { background-color: rgba(0,123,255,0.1); }
.btn-large { padding: calc(var(--spacing-unit) * 1.75) calc(var(--spacing-unit) * 3.5); font-size: 1.15rem; }
.btn-small { padding: calc(var(--spacing-unit) * 0.75) var(--spacing-unit); font-size: 0.8rem; }
.btn-icon { background: none; border: none; color: var(--text-secondary-color); font-size: 1.5rem; padding: var(--spacing-unit); cursor: pointer; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:hover { color: var(--primary-color); }
.btn-icon svg { width: 1em; height: 1em; fill: currentColor; display: block; }
.btn-file-upload { position: relative; overflow: hidden; display: inline-block; } .btn-file-upload input[type="file"] { position: absolute; top: 0; right: 0; bottom:0; left:0; width:100%; height:100%; font-size: 100px; opacity: 0; cursor: pointer; }

.form-group { margin-bottom: calc(var(--spacing-unit) * 2); }
.form-group label { display: block; margin-bottom: var(--spacing-unit); font-weight: 500; color: var(--text-secondary-color); font-size:0.9rem; }
.form-group select, .form-group input[type="text"], .form-group input[type="number"], .form-group input[type="email"], .form-group input[type="password"] { width: 100%; padding: calc(var(--spacing-unit) * 1.25); background-color: var(--on-surface-color); border: 1px solid var(--border-color); border-radius: var(--border-radius); color: var(--text-color); font-size: 0.95rem; }
.form-group select { appearance: none; -webkit-appearance: none; -moz-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23a0a0a0' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right calc(var(--spacing-unit) * 1.25) center; background-size: 1em; }
.form-group select:focus, .form-group input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25); }
.form-actions { display: flex; gap: var(--spacing-unit); width: 100%; justify-content: center; margin-top: calc(var(--spacing-unit)); }
.form-actions .btn { flex-grow: 1; margin: 0; max-width: 200px; }
.form-actions.column { flex-direction: column; align-items: center; }
.form-actions.column .btn { width: 100%; max-width: 350px; }

/* --- Common Box Styles --- */
.info-box, .stat-item.card,
.plan-builder-selected-exercises-section,
.plan-builder-available-exercises-section,
.new-exercise-display-area, .new-log-area, .logged-sets-container,
#plan-review-content .workout-day-review-item,
.set-timer-options {
    background-color: var(--surface-color);
    padding: calc(var(--spacing-unit) * 1.5);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-bottom: calc(var(--spacing-unit) * 1.5);
    width: 100%;
}
.info-box h3, .stat-item.card h3, .badges-display-area h4,
.plan-builder-selected-exercises-section h3,
.plan-builder-available-exercises-section h3,
.new-log-area h4, .logged-sets-container h4,
#plan-review-content .workout-day-review-item h4 {
    margin-top: 0; color: var(--primary-color); border-bottom: 1px solid var(--border-color);
    padding-bottom: calc(var(--spacing-unit) / 2); margin-bottom: var(--spacing-unit); font-size: 1.1rem;
}

.muscle-recovery-map-placeholder, .chart-placeholder, .new-video-placeholder {
    min-height: 150px; display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary-color); font-style: italic; text-align: center;
    background-color: var(--on-surface-color); border-radius: var(--border-radius);
    margin-bottom: var(--spacing-unit);
}
.new-video-placeholder { padding-top: 0; }
.exercise-video-link-container { text-align: center; margin-bottom: var(--spacing-unit); }
.exercise-video-link-container .btn-outline { width: auto; display: inline-block; }

/* --- Home Screens (Choice & Dashboard) --- */
#home-choice-screen .screen-header h1,
#active-plan-dashboard-screen .screen-header h1 { font-size: 1.5rem; }
.dashboard-content-wrapper { width:100%; max-width: 400px; display: flex; flex-direction: column; gap: var(--spacing-unit); }
.dashboard-focus { text-align:center; margin-bottom: var(--spacing-unit); }
#active-plan-dashboard-screen #dashboard-greeting { font-size: 1.5rem; margin-bottom: calc(var(--spacing-unit)*0.5); }
#active-plan-dashboard-screen #dashboard-sub-greeting { font-size: 0.9rem; margin-bottom: var(--spacing-unit); }
#active-plan-dashboard-screen #dashboard-start-gym-session-btn { margin-bottom: var(--spacing-unit); }
#active-plan-dashboard-screen .info-box h3,
#active-plan-dashboard-screen .badges-display-area h4 { font-size: 1rem; }
#reminder-message.reminder-message { background-color: var(--primary-color); color: white; padding: var(--spacing-unit); border-radius: var(--border-radius); text-align: center; margin: calc(var(--spacing-unit)*(-1)) auto var(--spacing-unit) auto; width:100%; max-width:calc(350px + var(--spacing-unit)*4); font-size:0.9rem; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.badges-display-area { display: flex; flex-wrap: wrap; gap: var(--spacing-unit); justify-content: center; padding-top: calc(var(--spacing-unit)/2); }

/* --- Plan Creation Flow --- */
.plan-builder-navigation { /* Moved to top, below header */
    display: flex;
    gap: var(--spacing-unit);
    justify-content: center;
    padding: var(--spacing-unit) 0;
    margin-bottom: var(--spacing-unit);
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}
.plan-builder-navigation .btn { flex-grow: 1; max-width: 220px; }

#plan-builder-screen .plan-builder-content { /* Holds the two list sections */
    display: flex;
    flex-direction: column;
    gap: var(--spacing-unit);
    flex-grow: 1; /* Allows content to fill space if screen isn't scrolling yet */
}
.plan-builder-selected-exercises-section,
.plan-builder-available-exercises-section {
    display: flex;
    flex-direction: column;
    /* These sections grow naturally with their content. No fixed heights. */
}
.plan-builder-selected-exercises-section h3,
.plan-builder-selected-exercises-section .day-actions,
.plan-builder-available-exercises-section h3,
.plan-builder-available-exercises-section .filters-and-search {
    flex-shrink: 0;
    /* margin-bottom is from common box style */
}
.day-actions { display: flex; gap: var(--spacing-unit); flex-wrap: wrap; }
.day-actions .btn-small { padding: calc(var(--spacing-unit)*0.6) var(--spacing-unit); font-size: 0.75rem; flex: 1 1 auto; min-width: 100px; max-width: 160px;}
#selected-exercises-for-day-list,
#available-exercises-list {
    list-style: none;
    padding: calc(var(--spacing-unit)/2);
    margin: 0;
    background-color: var(--on-surface-color);
    border-radius: calc(var(--border-radius) / 2);
    /* No internal scrolling, they grow with items. Page scrolls. */
}
#selected-exercises-for-day-list li { padding: var(--spacing-unit); border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; }
#selected-exercises-for-day-list li:last-child { border-bottom: none; }
#selected-exercises-for-day-list .exercise-name { flex-grow: 1; margin-right: var(--spacing-unit); }
#selected-exercises-for-day-list .btn-remove-ex { background: none; border: none; color: var(--danger-color); cursor: pointer; font-size: 1.4rem; padding: calc(var(--spacing-unit)/2); line-height: 1; }
.filters-and-search { display: flex; flex-direction: column; gap: var(--spacing-unit); }
.filters-and-search .form-group { margin-bottom: 0; }
#available-exercises-list li { padding: calc(var(--spacing-unit)*0.75) var(--spacing-unit); border-bottom: 1px solid var(--on-surface-color); display: flex; justify-content: space-between; align-items: center; transition: background-color 0.2s; font-size: 0.9rem; }
#available-exercises-list li:hover { background-color: var(--on-surface-color); }
#available-exercises-list li > span { flex-grow: 1; }
#available-exercises-list li .btn-add-ex-icon { background: none; border: none; color: var(--success-color); font-size: 1.6rem; font-weight: bold; cursor: pointer; padding: calc(var(--spacing-unit)/4) calc(var(--spacing-unit)/2); line-height: 1; margin-left: var(--spacing-unit); flex-shrink: 0; }
#available-exercises-list li .btn-add-ex-icon:hover { color: var(--success-color-hover); }

/* Plan Review Screen */
#plan-review-content .workout-day-review-item h5 { margin: 0 0 calc(var(--spacing-unit)/2) 0; font-size: 1.05rem; }
.exercise-config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: calc(var(--spacing-unit) * 0.75); align-items: end; }
.exercise-config-grid .form-group { margin-bottom: 0; }
.exercise-config-grid label { font-size: 0.7rem; text-transform: uppercase; margin-bottom: calc(var(--spacing-unit) / 4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exercise-config-grid input[type="number"], .exercise-config-grid input[type="text"], .exercise-config-grid select { padding: calc(var(--spacing-unit) * 0.75); font-size: 0.85rem; }

/* --- Workout Session (NEW UI Styles) --- */
.new-workout-layout { display: flex; height: 100%; gap: var(--spacing-unit); }
.new-workout-sidebar { width: 130px; flex-shrink: 0; background-color: var(--surface-color); padding: calc(var(--spacing-unit) * 0.75); border-radius: var(--border-radius); display: flex; flex-direction: column; border: 1px solid var(--border-color); overflow-y: auto; }
.new-workout-sidebar h3 { margin-top: 0; margin-bottom: calc(var(--spacing-unit) * 0.75); padding-bottom: calc(var(--spacing-unit) * 0.75); border-bottom: 1px solid var(--border-color); font-size: 0.9rem; color: var(--primary-color); text-align: center; }
#new-workout-exercise-list { list-style: none; padding: 0; margin: 0 0 calc(var(--spacing-unit) * 0.5) 0; flex-grow: 1; }
#new-workout-exercise-list li { padding: calc(var(--spacing-unit) * 0.5); margin-bottom: calc(var(--spacing-unit) / 3); border-radius: calc(var(--border-radius) / 2.5); cursor: pointer; transition: background-color 0.2s, color 0.2s; font-size: 0.75rem; border: 1px solid transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
#new-workout-exercise-list li:hover { background-color: var(--on-surface-color); }
#new-workout-exercise-list li.active { background-color: var(--primary-color); color: #fff; font-weight: bold; }
#new-workout-exercise-list li.completed { text-decoration: line-through; opacity: 0.6; }
#new-workout-exercise-list li.completed.active { opacity: 1; background-color: var(--success-color); }
#new-workout-exercise-list li.skipped-temporarily { opacity: 0.7; font-style: italic; color: var(--text-secondary-color); }
#new-workout-exercise-list li.skipped-temporarily.active { background-color: var(--info-color); color: #fff; font-style: normal; opacity: 1; }
.new-workout-progress-container { margin-top: auto; padding-top: var(--spacing-unit); }
.new-workout-progress-container .progress-bar-container { margin-bottom: calc(var(--spacing-unit)/3); height: 8px; background-color: var(--on-surface-color); border-radius: 4px; overflow:hidden; }
.new-workout-progress-container .progress-bar-fill { height:100%; background-color: var(--success-color); width:0%; transition: width 0.3s ease;}
.new-workout-progress-container p { text-align: center; font-size: 0.7rem; margin: 0; line-height: 1.2; }

.new-workout-main { flex-grow: 1; display: flex; flex-direction: column; overflow-y: auto; min-width: 0; }
.new-workout-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: var(--spacing-unit); margin-bottom: var(--spacing-unit); border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.new-workout-header .plan-info { display: flex; align-items: baseline; gap: calc(var(--spacing-unit) * 0.75); flex-wrap: wrap; }
.new-workout-header .plan-info h1 { margin: 0; font-size: 1.2rem; }
.new-workout-header .plan-info p { margin: 0; font-size: 0.9rem; color: var(--text-secondary-color); }
.new-workout-header .session-meta { text-align: right; display:flex; flex-direction:column; align-items: flex-end; gap: calc(var(--spacing-unit)/2); }
.session-difficulty-label { font-size:0.8rem; color: var(--text-secondary-color); margin-bottom: 2px; }
#session-difficulty-override-select { font-size: 0.85rem; padding: calc(var(--spacing-unit)/2); background-color: var(--on-surface-color); border-color: var(--border-color); color: var(--text-color); border-radius: calc(var(--border-radius)/2); width: auto; min-width: 180px; /* Wider for "Level X: Name" */ }

.new-exercise-display-area { flex-grow: 1; display: flex; flex-direction: column;} /* common box style applies */
.new-exercise-display-area h2 { margin-top: 0; margin-bottom: calc(var(--spacing-unit)/2); font-size: 1.6rem; color: var(--primary-color); text-align: center; }
#new-exercise-target-info { text-align: center; font-size: 0.9rem; color: var(--text-secondary-color); margin-bottom: var(--spacing-unit); }
.new-muscles-highlighted { text-align: center; font-style: italic; color: var(--text-secondary-color); margin-bottom: var(--spacing-unit); font-size: 0.85rem; }

.timer-controls-area { display: flex; flex-direction: column; align-items: center; margin-bottom: var(--spacing-unit); padding: calc(var(--spacing-unit) / 2); }
.timer-controls-area .countdown-message { width: 100%; max-width: 300px; margin: 0 auto calc(var(--spacing-unit)/1.5) auto; font-size: 1.3rem; font-weight: bold; padding: calc(var(--spacing-unit) /2 ); background-color: var(--on-surface-color); border-radius: var(--border-radius); }
#new-exercise-start-countdown {color: var(--primary-color);}
#new-active-set-timer-display { font-size: 1.5rem; color: var(--success-color); }
#new-rest-timer-display { color: var(--info-color); }
.timer-toggle-button { display: inline-flex; align-items: center; justify-content: center; gap: calc(var(--spacing-unit) / 2); min-width: 150px; padding: calc(var(--spacing-unit)*0.75) var(--spacing-unit); }
.timer-toggle-button svg { vertical-align: middle; } /* Already has margin-right from JS */

.set-timer-options { margin-bottom: var(--spacing-unit); padding: var(--spacing-unit); background-color: var(--surface-color); border-radius: var(--border-radius); width:100%; max-width:320px; margin-left:auto; margin-right:auto;} /* Common box style applies */
.set-timer-options .set-timer-mode-label { display: block; margin-bottom: 4px; font-size: 0.85rem; color: var(--text-secondary-color); text-align: center; }
.timer-mode-buttons { display: flex; gap: var(--spacing-unit); margin-bottom: calc(var(--spacing-unit) / 2); }
.timer-mode-buttons .timer-mode-btn { flex: 1; font-size:0.8rem; }
.timer-mode-buttons .timer-mode-btn.active { background-color: var(--primary-color); color: #fff; border-color: var(--primary-color); }
#countdown-duration-input-container { margin-top: calc(var(--spacing-unit) / 1.5); text-align: center; }
#countdown-duration-input-container label { font-size: 0.8rem; color: var(--text-secondary-color); margin-right: calc(var(--spacing-unit) / 2); display: inline-block; vertical-align: middle; }
#set-countdown-duration { width: 70px; padding: calc(var(--spacing-unit) * 0.5) calc(var(--spacing-unit) * 0.75); font-size: 0.9rem; text-align: center; display: inline-block; vertical-align: middle; background-color: var(--background-color); border: 1px solid var(--border-color); border-radius:var(--border-radius); color: var(--text-color); }

.new-log-area #new-start-current-exercise-btn { width:100%; margin-bottom: var(--spacing-unit); }
#set-logging-inputs .form-group { margin-bottom: var(--spacing-unit); }
#set-logging-inputs .btn-large { width:100%; }

.logged-sets-container { padding-top: calc(var(--spacing-unit)/2); padding-bottom: calc(var(--spacing-unit)/2); }
.logged-sets-container h4 { font-size: 0.9rem; border-bottom:none; margin-bottom:calc(var(--spacing-unit)/2); }
.logged-sets-container ul.sets-list-items { list-style:none; padding:0; margin:0; }
.logged-sets-container .logged-set-item { padding: calc(var(--spacing-unit)/2); border-bottom: 1px dashed var(--border-color); font-size:0.85rem; }
.logged-sets-container .logged-set-item:last-child { border-bottom: none; }
.logged-sets-container .no-sets-placeholder { font-size:0.85rem; }

.new-workout-footer-actions { display: flex; gap: var(--spacing-unit); padding-top: var(--spacing-unit); margin-top: auto; border-top: 1px solid var(--border-color); flex-shrink: 0; }
.new-workout-footer-actions .btn { flex-grow: 1; margin:0; }

/* --- Stats Screen --- */
.stats-filters { margin-bottom: var(--spacing-unit); display: flex; gap: var(--spacing-unit); justify-content: center; flex-wrap: wrap; }
.stats-filters .btn.active { background-color: var(--primary-color); color: #fff; }
.stats-content-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--spacing-unit); }
/* .stat-item.card uses common box style */
.key-metrics-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--spacing-unit); text-align: center; }
.key-metrics-container p { margin:0; font-size: 0.9rem; }
.key-metrics-container .stat-value { font-size: 1.5rem; font-weight: bold; color: var(--primary-color); }
.chart-container { position: relative; height: 250px; margin-top: var(--spacing-unit); background-color: var(--surface-color); padding:var(--spacing-unit); border-radius: var(--border-radius); border: 1px solid var(--border-color);}
.chart-caption { text-align:center; font-size:0.8rem; color:var(--text-secondary-color); margin-top: calc(var(--spacing-unit)/2); }
#stats-exercise-select { margin-bottom: var(--spacing-unit); }
/* #stats-screen-badges-container uses common .badges-display-area */
.photo-upload-area { display: flex; gap: var(--spacing-unit); margin-bottom: var(--spacing-unit); flex-wrap: wrap; }
.photo-upload-area .btn-file-upload { flex: 1 1 150px; min-width: 150px; }
.photo-comparison-selectors { display: flex; gap: var(--spacing-unit); margin-bottom: var(--spacing-unit); flex-wrap: wrap; }
.photo-comparison-selectors .form-group { flex: 1 1 150px; min-width: 150px; margin-bottom: 0; }
.photo-comparison-display { display: flex; justify-content: space-around; gap: var(--spacing-unit); margin-top: var(--spacing-unit); flex-wrap: wrap; }
.photo-compare-container { flex-basis: 48%; min-width: 150px; text-align: center; margin-bottom: var(--spacing-unit); }
.photo-compare-container img { width: 100%; height: auto; max-height: 250px; object-fit: contain; border: 1px solid var(--border-color); border-radius: var(--border-radius); margin-bottom: calc(var(--spacing-unit) / 2); background-color: var(--on-surface-color); min-height:100px; }
.photo-compare-container p { font-size: 0.8rem; color: var(--text-secondary-color); margin-top:0; }
.badge-item { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--spacing-unit); background-color: var(--on-surface-color); border-radius: var(--border-radius); width: 80px; height: 80px; text-align: center; border: 1px solid var(--border-color); }
.badge-icon { font-size: 2.5rem; margin-bottom: calc(var(--spacing-unit) / 2); line-height: 1; }
.badge-name { font-size: 0.7rem; color: var(--text-secondary-color); line-height: 1.2; word-break: break-word; }

/* --- Settings Screen --- */
.settings-divider { margin: calc(var(--spacing-unit) * 2) 0; border-color: var(--border-color); border-style: solid; border-width: 1px 0 0 0;}
#settings-screen .info-box { text-align: left; max-width: none; background-color: var(--on-surface-color); }
#active-profile-display .active-profile-info-header { display: flex; justify-content: space-between; align-items: center; }
#active-profile-display .active-profile-info-header p { margin-top:0; margin-bottom: 0; flex-grow:1; }
#active-profile-display .btn-icon { color: var(--primary-color); }
#settings-screen h3 { color: var(--primary-color); margin-top: calc(var(--spacing-unit) * 2); margin-bottom: var(--spacing-unit); border-bottom: 1px solid var(--border-color); padding-bottom: calc(var(--spacing-unit) / 2); }
#settings-create-new-plan-btn { margin-top: var(--spacing-unit); width:100%; max-width: 350px; margin-left:auto; margin-right:auto;}
.training-plan-item { background-color: var(--on-surface-color); padding: var(--spacing-unit); margin-bottom: var(--spacing-unit); border: 1px solid var(--border-color); border-radius: var(--border-radius); }
.plan-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: calc(var(--spacing-unit) / 2) 0; }
.training-plan-item .plan-info { /* More specific selector for plan list item */
    display: flex; flex-direction: column; flex-grow: 1;
}
.plan-name { font-weight: bold; font-size: 1.1em; color: var(--text-color); margin-bottom: calc(var(--spacing-unit) / 4); }
.plan-details { font-size: 0.85em; color: var(--text-secondary-color); display: block; }
.plan-status { font-size: 0.8em; margin-left: var(--spacing-unit); color: var(--text-secondary-color); white-space: nowrap; align-self: center; }
.plan-status.active { color: var(--success-color); font-weight: bold; }
.plan-toggle-arrow { font-size: 1em; margin-left: var(--spacing-unit); color: var(--text-secondary-color); user-select: none; align-self: center; line-height: 1; display: inline-flex; align-items: center; }
.plan-toggle-arrow svg { width: 1em; height: 1em; fill: currentColor; }
.plan-actions { display: none; flex-direction: column; gap: calc(var(--spacing-unit) / 2); padding-top: var(--spacing-unit); margin-top: var(--spacing-unit); border-top: 1px dashed var(--border-color); }
.plan-actions .btn-small { width: 100%; margin: 0; text-align: left; padding-left: var(--spacing-unit); background-color: var(--secondary-color); }
.plan-actions .btn-small.delete { background-color: var(--danger-color); }

/* --- Bottom Navigation Bar --- */
#bottom-nav {
    display: none; /* JS controls visibility */
    justify-content: space-around;
    align-items: stretch; /* Make buttons fill height */
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    height: 60px; /* Or your desired height */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    flex-shrink: 0;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-secondary-color);
    cursor: pointer;
    height: 100%; /* Fill height */
    padding: calc(var(--spacing-unit)/2) calc(var(--spacing-unit)/2);
    font-size: 0.75rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: calc(var(--spacing-unit) / 4);
    flex-grow: 1; /* Distribute space equally */
    flex-basis: 0; /* Allow equal shrinking/growing */
    transition: color 0.2s ease, background-color 0.2s ease;
    min-width: 0; /* For flex basis to work correctly */
    border-left: 1px solid var(--border-color); /* Optional: separator lines */
}
.nav-btn:first-child {
    border-left: none;
}
.nav-btn:hover, .nav-btn.active {
    color: var(--primary-color);
    background-color: var(--on-surface-color); /* Subtle hover/active background */
}
.nav-icon {
    font-size: 1.5rem; /* Adjust as needed for icons */
    line-height: 1; /* Prevent extra space */
}
.nav-text {
    font-size: 0.7rem; /* Adjust as needed */
    line-height: 1.1;
    margin-top: 2px;
}

/* --- Modals --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.65); display: none; align-items: center; justify-content: center; z-index: 2000; padding: var(--spacing-unit); opacity: 0; transition: opacity 0.25s ease-in-out; }
.modal-overlay.visible { display: flex; opacity: 1; }
.app-modal { background-color: var(--surface-color); padding: calc(var(--spacing-unit) * 2); border-radius: var(--border-radius); border: 1px solid var(--border-color); box-shadow: 0 6px 18px rgba(0,0,0,0.35); width: 90%; max-width: 420px; max-height: 85vh; display: flex; flex-direction: column; transform: scale(0.9); opacity: 0; transition: transform 0.25s ease-out, opacity 0.2s ease-in-out; }
.modal-overlay.visible .app-modal { transform: scale(1); opacity: 1; }
.app-modal .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--spacing-unit); padding-bottom: var(--spacing-unit); border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.app-modal .modal-header h3 { margin: 0; color: var(--primary-color); font-size: 1.25rem; }
.app-modal .modal-close-btn { background: none; border: none; font-size: 1.8rem; color: var(--text-secondary-color); cursor: pointer; line-height: 1; padding: calc(var(--spacing-unit) / 2); margin: calc(var(--spacing-unit) / -2); }
.app-modal .modal-close-btn:hover { color: var(--danger-color); }
.app-modal .modal-body { margin-bottom: calc(var(--spacing-unit) * 1.5); overflow-y: auto; line-height: 1.6; font-size: 0.95rem; flex-grow: 1; }
.app-modal .modal-body p { margin-top: 0; margin-bottom: 0; word-wrap: break-word; }
.app-modal .modal-footer { display: flex; justify-content: flex-end; gap: var(--spacing-unit); padding-top: var(--spacing-unit); border-top: 1px solid var(--border-color); flex-shrink: 0; }
.app-modal .modal-footer .btn { min-width: 90px; width: auto; flex-grow: 0; margin: 0; padding: calc(var(--spacing-unit)*1) calc(var(--spacing-unit)*1.5); font-size: 0.9rem;}
#swap-exercise-list { list-style: none; padding: 0; margin: 0; overflow-y: auto; flex-grow: 1; }
#swap-exercise-list li { padding: calc(var(--spacing-unit) * 1.2); cursor: pointer; border-bottom: 1px solid var(--on-surface-color); transition: background-color 0.2s ease; }
#swap-exercise-list li:last-child { border-bottom: none; }
#swap-exercise-list li:hover { background-color: var(--on-surface-color); }

/* --- AI Chat Widget --- */
#ai-chat-widget {
    position: fixed;
    /* Default positioning for larger screens (bottom-right) */
    bottom: calc(60px + var(--spacing-unit) * 2); /* Above nav bar (60px) + some spacing */
    right: calc(var(--spacing-unit) * 2);
    
    width: 320px; /* Default width for larger screens */
    max-width: calc(100vw - var(--spacing-unit) * 4); /* Ensure it doesn't exceed viewport width minus padding */
    height: 450px; /* Default height */
    max-height: calc(100vh - 60px - var(--spacing-unit) * 4); /* Max height considering nav bar and some spacing */
    
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px rgba(0,0,0,0.25); /* Slightly more pronounced shadow */
    
    display: none; /* JS toggles this to 'flex' when open */
    flex-direction: column;
    z-index: 1002; /* Above nav bar (1000) and FAB (1001 if it were still separate) */
    border: 1px solid var(--border-color);
    overflow: hidden; /* Contents will scroll internally */
    
    /* Animation for opening/closing */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

#ai-chat-widget.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    display: flex; /* This is important for the flex children to layout correctly */
}

#ai-chat-header {
    background-color: var(--on-surface-color);
    padding: calc(var(--spacing-unit) * 1.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0; /* Header should not shrink */
}

#ai-chat-header span { /* Title "eFitAI Assistant" */
    font-weight: bold;
    color: var(--text-color);
    font-size: 1.05rem;
}

#ai-chat-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary-color);
    font-size: 1.5rem; /* Adjust size of '×' */
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    padding: calc(var(--spacing-unit) / 2);
}
#ai-chat-close-btn:hover {
    color: var(--danger-color);
}

#ai-chat-messages {
    flex-grow: 1; /* Takes up available space */
    padding: var(--spacing-unit);
    overflow-y: auto; /* Scrollable messages area */
    display: flex;
    flex-direction: column;
    gap: var(--spacing-unit);
}

.chat-message {
    display: flex;
    max-width: 85%;
    word-wrap: break-word; /* Ensure long words break */
}
.chat-message .message-bubble {
    padding: var(--spacing-unit) calc(var(--spacing-unit) * 1.5);
    border-radius: var(--border-radius);
    line-height: 1.4;
    font-size: 0.9rem;
}

.user-message { align-self: flex-end; }
.user-message .message-bubble {
    background-color: var(--primary-color);
    color: #fff;
    border-bottom-right-radius: calc(var(--border-radius) / 3); /* For "tailed" bubble */
}

.ai-message { align-self: flex-start; }
.ai-message .message-bubble {
    background-color: var(--success-color); /* Or a neutral AI color like secondary-color */
    color: #fff;
    border-bottom-left-radius: calc(var(--border-radius) / 3);
}

#ai-chat-input-area {
    display: flex;
    padding: var(--spacing-unit);
    border-top: 1px solid var(--border-color);
    background-color: var(--on-surface-color);
    align-items: center;
    flex-shrink: 0; /* Footer should not shrink */
}

#ai-chat-input {
    flex-grow: 1;
    padding: calc(var(--spacing-unit) * 1.2);
    border: 1px solid var(--border-color);
    border-radius: calc(var(--border-radius) * 2); /* More rounded input */
    background-color: var(--background-color); /* Or var(--surface-color) */
    color: var(--text-color);
    font-size: 0.9rem;
    margin-right: var(--spacing-unit);
}
#ai-chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0,123,255,0.2); /* Subtle focus shadow */
}

#ai-chat-send-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0; /* Remove padding if using fixed size */
    transition: background-color 0.2s ease;
}
#ai-chat-send-btn:hover {
    background-color: var(--primary-color-hover);
}
#ai-chat-send-btn svg { /* Ensure SVG inside is centered and sized well */
    width: 18px; height: 18px;
}

.ai-chat-nav-btn .nav-icon svg { /* Ensure SVG size within nav button is consistent */
    width: 1.5rem; /* Match .nav-icon font-size */
    height: 1.5rem;
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    html { font-size: 15px; }
    .new-workout-layout { flex-direction: column; }
    .new-workout-sidebar { width: 100%; max-height: 180px; margin-bottom: var(--spacing-unit); }
    #new-workout-exercise-list { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: calc(var(--spacing-unit) / 2); padding-bottom: var(--spacing-unit); }
    #new-workout-exercise-list li { flex-shrink:0; min-width: 100px; text-align: center; }
    /* .plan-builder-selected-exercises-section { max-height: none; } -- Not needed with page scroll */
    .photo-comparison-display { flex-direction: column; align-items: center; } .photo-compare-container { flex-basis: 80%; }
    .stats-content-grid { grid-template-columns: 1fr; }
}

.new-workout-sidebar { 
        /* If not stacking, this might not need to be full width anymore at 768px */
        /* width: 100%; max-height: 180px;  */ /* Adjust if keeping side-by-side */
        margin-bottom: var(--spacing-unit); 
    }

@media (max-width: 480px) {
    html { font-size: 14px; }
    .screen { padding: var(--spacing-unit); padding-bottom: calc(60px + var(--spacing-unit) * 2); }
    /* Removed specific padding override for #plan-builder-screen .screen-content as it doesn't have its own sticky footer anymore */
    #plan-review-screen .screen-content { padding-bottom: calc(50px + var(--spacing-unit) * 1.5); } /* For plan review's sticky footer */
    .screen-header > h1, .screen-header .header-with-back h1 { font-size: 1.3rem; }
    .btn { padding: calc(var(--spacing-unit) * 1.1) calc(var(--spacing-unit) * 1.8); font-size: 0.9rem; }
    .btn-large { font-size: 1rem; }
    /* .new-log-area .form-group { grid-template-columns: 1fr; } -- If it was grid, it's not anymore by default */
    .new-workout-footer-actions { flex-direction: column; }
    .new-workout-footer-actions .btn { width: 100%; }
    .new-video-placeholder { min-height: 120px; }
    .photo-upload-area, .photo-comparison-selectors { flex-direction: column; }
    .badge-item { width: 70px; height: 70px; } .badge-icon { font-size: 2rem; }
    .exercise-config-grid { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
    .day-actions .btn-small { min-width: 70px; font-size: 0.7rem; }
    #ai-chat-widget {
        width: calc(100% - var(--spacing-unit) * 2); /* Full width minus side spacing */
        right: var(--spacing-unit);
        bottom: calc(60px + var(--spacing-unit)); /* Position above the 60px nav bar + a little space */
        max-height: 65vh; /* Take up more vertical space on mobile */
        height: auto; /* Let content determine height up to max-height */
        /* Remove fixed height from desktop to allow it to be more flexible on mobile */
    }
    .app-modal { width: 95%; padding: var(--spacing-unit); }
}
@media (max-width: 360px) {
    html { font-size: 13px; }
    .nav-text { display: none; } .nav-icon { font-size: 1.6rem; }
    .new-workout-header .plan-info h1 { font-size: 1.1rem; }
    .new-workout-header .session-meta { flex-direction: column; align-items: flex-end; /* Stack difficulty for very small screens */ }
    #session-difficulty-override-select {min-width: 100%; font-size:0.8rem;} /* Make select full width if stacked */
    .plan-actions { flex-direction: column; }
}

/* --- Light Theme --- */
body.light-theme {
    --background-color: #f4f6f8; --surface-color: #ffffff; --on-surface-color: #e9ecef;
    --text-color: #212529; --text-secondary-color: #6c757d; --border-color: #dee2e6;
}
body.light-theme #reminder-message.reminder-message { background-color: var(--primary-color); color: #fff; }
body.light-theme .btn-primary, body.light-theme .btn-success, body.light-theme .btn-danger, body.light-theme .btn-secondary, body.light-theme .btn-info, body.light-theme .btn-warning { color: #fff; }
body.light-theme .btn-warning { color: #000; }
body.light-theme .btn-outline { color: var(--primary-color); border-color: var(--primary-color); }
body.light-theme .btn-outline:hover { background-color: rgba(0,123,255,0.05); }
body.light-theme #ai-fab-chat-toggle, body.light-theme #ai-chat-send-btn { background-color: var(--primary-color); color: white; }
body.light-theme .user-message .message-bubble { background-color: var(--primary-color); color: #fff; }
body.light-theme .ai-message .message-bubble { background-color: var(--success-color); color: #fff; }
body.light-theme .btn-icon.back-button { color: var(--text-color); }
body.light-theme .btn-icon:hover { color: var(--primary-color); }
body.light-theme #active-profile-display .btn-icon { color: var(--primary-color); }
body.light-theme .timer-mode-buttons .timer-mode-btn.active { background-color: var(--primary-color); color: #fff; border-color: var(--primary-color); }
body.light-theme .input-needs-attention { border-color: var(--danger-color) !important; box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.15) !important; }
body.light-theme .input-needs-attention:focus { border-color: var(--primary-color) !important; box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.15) !important; }
body.light-theme #new-workout-exercise-list li.active { background-color: var(--primary-color); color: #fff; }
body.light-theme #new-workout-exercise-list li.completed.active { background-color: var(--success-color); color: #fff; }
body.light-theme #new-workout-exercise-list li.skipped-temporarily.active { background-color: var(--info-color); color: #fff;}
body.light-theme #selected-exercises-for-day-list, body.light-theme #available-exercises-list { background-color: var(--on-surface-color); }
body.light-theme .timer-controls-area .countdown-message { background-color: var(--on-surface-color); }
body.light-theme #set-countdown-duration { background-color: var(--background-color); border-color: var(--border-color); color: var(--text-color); }
body.light-theme .chart-container { background-color: var(--surface-color); border: 1px solid var(--border-color); }
body.light-theme .new-workout-sidebar { background-color: var(--surface-color); border-color: var(--border-color); }