/* ============================================================
   FamilyGYM — Clean Professional Design System
   ============================================================ */

/* --- Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* --- Custom Properties: Light Theme --- */
:root {
    /* Brand palette */
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --blue-light: #60a5fa;
    --green: #22c55e;
    --green-light: #86efac;
    --amber: #f59e0b;
    --amber-light: #fde68a;
    --red: #ef4444;
    --red-light: #fca5a5;

    /* Surfaces */
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;

    /* Text */
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* Borders */
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);

    /* Transitions */
    --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Legacy aliases (backward compat) */
    --primary: var(--blue);
    --primary-dark: var(--blue-dark);
    --primary-light: var(--blue-light);
    --success: var(--green);
    --warning: var(--amber);
    --danger: var(--red);
    --bg-card: var(--surface);
    --shadow: var(--shadow-md);
}

/* --- Dark Theme --- */
[data-theme="dark"] {
    --blue: #3b82f6;
    --blue-dark: #2563eb;
    --blue-light: #60a5fa;
    --green: #22c55e;
    --green-light: #4ade80;
    --amber: #fbbf24;
    --amber-light: #fde68a;
    --red: #f87171;
    --red-light: #fca5a5;

    --bg: #0a0e1a;
    --surface: #131825;
    --surface-hover: #1c2236;

    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --border: #1e293b;
    --border-light: #1a2332;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);

    --primary: var(--blue);
    --primary-dark: var(--blue-dark);
    --primary-light: var(--blue-light);
    --success: var(--green);
    --warning: var(--amber);
    --danger: var(--red);
    --bg-card: var(--surface);
    --shadow: var(--shadow-md);
}

/* --- Base --- */
html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
        Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 15px;
    letter-spacing: -0.01em;
}

/* --- App Shell --- */
.app-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 1.25rem 1rem;
    min-height: 100vh;
}

/* --- Header --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-icon {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--blue);
    color: white;
    border-color: var(--blue);
    box-shadow: var(--shadow-sm);
}

/* --- Main Navigation --- */
.main-nav {
    display: flex;
    position: relative;
    isolation: isolate;
    gap: 0.375rem;
    margin-bottom: 1.75rem;
    background: var(--surface);
    padding: 0.375rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.nav-indicator {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
    border-radius: var(--radius-md);
    background: var(--blue);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.24);
    pointer-events: none;
    transition: transform 460ms cubic-bezier(0.22, 1, 0.36, 1), width 460ms cubic-bezier(0.22, 1, 0.36, 1), height 460ms cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-btn {
    position: relative;
    z-index: 1;
    flex: 1;
    padding: 0.625rem 0.75rem;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.825rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    line-height: 1;
}

.nav-btn:hover {
    background: var(--surface-hover);
    color: var(--text-secondary);
}

.nav-btn.active {
    background: transparent;
    color: white;
    box-shadow: none;
}

/* --- Sections --- */
.section {
    display: none;
}

.section.active {
    display: block;
    animation: sectionEnter 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sectionEnter {
    from { opacity: 0; transform: translateY(12px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.nav-btn.active {
    animation: navPop 0.25s ease;
}

@keyframes navPop {
    0% { transform: scale(0.95); }
    60% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.btn-reset {
    background: var(--red);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-reset:hover {
    background: #dc2626;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* --- Calendar Section --- */
.calendar-section {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.calendar-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.calendar-controls button,
.calendar-controls .month-year {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: none;
    background: var(--blue);
    color: white;
    font-size: 0.925rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.calendar-controls button:hover,
.calendar-controls .month-year:hover {
    background: var(--blue-dark);
}

.month-year {
    text-align: center;
    min-width: 160px;
}

/* --- View Selector --- */
.view-selector {
    display: flex;
    gap: 0.375rem;
    margin-bottom: 1rem;
    background: var(--surface-hover);
    padding: 0.375rem;
    border-radius: var(--radius-md);
}

.view-btn, .history-view-btn {
    flex: 1;
    padding: 0.625rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.825rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.view-btn.active, .history-view-btn.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* --- Calendar Grid --- */
.calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.35rem;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.calendar.view-day {
    grid-template-columns: 1fr;
}

.single-day-cell {
    min-height: 9rem;
    flex-direction: column;
    gap: 0.35rem;
}

.single-day-cell .day-name {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.single-day-cell .day-number {
    font-size: 3rem;
    line-height: 1;
    letter-spacing: -0.04em;
}

.single-day-cell.today .day-name {
    color: inherit;
}

.weekday-header {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 0.25rem;
}

.day-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 3.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.day-cell.empty {
    background: transparent;
    border-color: transparent;
    cursor: default;
}

.day-cell.today {
    background: var(--blue-light);
    color: white;
    font-weight: 600;
}

.day-cell:hover:not(.empty) {
    transform: scale(1.04);
    box-shadow: var(--shadow-sm);
}

.day-cell.has-workout {
    background: linear-gradient(135deg, var(--green), var(--blue));
    color: white;
    font-weight: 600;
}

.day-cell.selected {
    border: 2.5px solid var(--amber);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}

.day-cell.today.has-workout {
    background: linear-gradient(135deg, #84cc16, var(--green));
}

.day-number {
    font-weight: 700;
}

.workout-count {
    position: absolute;
    right: 0.25rem;
    bottom: 0.2rem;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: var(--blue);
    color: white;
    font-size: 0.65rem;
    line-height: 1.1rem;
    text-align: center;
    font-weight: 700;
}

.week-day-cell {
    min-height: 5.25rem;
    flex-direction: column;
    gap: 0.25rem;
    justify-content: center;
}

.week-day-cell .day-number {
    font-size: 1.4rem;
}

/* --- Modal / Dialog --- */
dialog {
    margin: auto;
    padding: 0;
    border: none;
    border-radius: var(--radius-xl);
    max-width: 90vw;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
}

.modal-content {
    padding: 1.5rem;
}

#selectedDate {
    display: block;
    margin-bottom: 0.75rem;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--blue);
    letter-spacing: -0.02em;
}

.input-field {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.925rem;
    margin-bottom: 0.5rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-field:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

fieldset {
    border: none;
    padding: 0;
    margin: 0 0 1rem 0;
}

legend {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    padding: 0 0.25rem;
}

/* --- Cardio List (dentro del modal de día) --- */
.cardio-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    margin-bottom: 1rem;
    max-height: 30vh;
    overflow-y: auto;
}

.cardio-empty {
    text-align: center;
    padding: 0.75rem;
    font-size: 0.85rem;
}

.cardio-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--surface-hover);
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    border: 1px solid var(--border);
}

.cardio-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: var(--radius-md);
}

.cardio-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.cardio-type-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.cardio-item-details {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Cardio Modal Form --- */
.cardio-form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.625rem;
    margin: 0.75rem 0;
}

.cardio-form-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.cardio-form-field label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* --- Cardio Stats Subtitle --- */
.stats-subtitle {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin: 0.25rem 0 0.75rem;
    letter-spacing: -0.02em;
}


.exercises-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    margin-bottom: 1rem;
    max-height: 40vh;
    overflow-y: auto;
}

.exercise-item {
    background: var(--surface-hover);
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    border: 1px solid var(--border);
}

.exercise-name {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.exercise-name span:first-child {
    font-weight: 600;
    font-size: 0.95rem;
}

.delete-btn {
    background: transparent;
    border: none;
    color: var(--red);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all var(--transition);
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* --- Series Inputs --- */
.series-inputs {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;
}

.series-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.series-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.series-input {
    width: 100%;
    padding: 0.45rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    text-align: center;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition);
}

.series-input:focus {
    outline: none;
    border-color: var(--blue);
}

.add-series-btn {
    width: 100%;
    padding: 0.5rem;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.825rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.add-series-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}

/* --- Exercise Panels (Accordion) --- */
.exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    cursor: pointer;
    background: var(--surface-hover);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    transition: background var(--transition);
}

.exercise-header:hover {
    background: var(--border);
}

.exercise-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-icon {
    color: var(--text-muted);
    font-size: 0.875rem;
    transition: transform 0.2s;
}

.exercise-panel {
    display: none;
    padding: 0 0.75rem 0.75rem;
}

/* --- Muscle Group Panels --- */
.muscle-group-panel {
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.muscle-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    cursor: pointer;
    background: var(--surface-hover);
    transition: background var(--transition);
}

.muscle-group-header:hover {
    background: var(--border);
}

.muscle-group-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--blue);
    letter-spacing: -0.01em;
}

.muscle-group-content {
    display: none;
    padding: 0.75rem;
    background: var(--surface);
}

/* --- Sets --- */
.sets-container {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.set-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.5rem;
    background: var(--surface-hover);
    border-radius: var(--radius-sm);
}

.set-number {
    font-size: 0.725rem;
    color: var(--text-muted);
    font-weight: 600;
    min-width: 60px;
}

.weight-input,
.reps-input {
    flex: 1;
    padding: 0.45rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition);
}

.weight-input:focus,
.reps-input:focus {
    outline: none;
    border-color: var(--blue);
}

.remove-set-btn {
    background: transparent;
    border: none;
    color: var(--red);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: all var(--transition);
}

.remove-set-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

.add-set-btn {
    width: 100%;
    padding: 0.5rem;
    border: 1.5px dashed var(--blue);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--blue);
    font-size: 0.825rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.add-set-btn:hover {
    background: var(--blue);
    color: white;
}

/* --- Favorite Exercises Modal --- */
.favorite-exercises-list {
    max-height: 50vh;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.muscle-group-section {
    margin-bottom: 1.5rem;
}

.muscle-group-section h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--blue);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1.5px solid var(--border);
    letter-spacing: -0.01em;
}

.exercises-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}

.exercise-favorite-btn {
    padding: 0.7rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: 0.825rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}

.exercise-favorite-btn:hover {
    border-color: var(--blue);
    background: var(--blue);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.manual-exercise {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1.5px solid var(--border);
}

.manual-exercise .input-field {
    flex: 1;
    margin-bottom: 0;
}

.manual-exercise .btn-secondary {
    white-space: nowrap;
}

/* --- Buttons --- */
.btn-primary,
.btn-save {
    background: var(--blue);
    color: white;
    border: none;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.btn-primary:hover,
.btn-save:hover {
    background: var(--blue-dark);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-cancel {
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid var(--border);
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    cursor: pointer;
    width: 100%;
    transition: all var(--transition);
}

.btn-cancel:hover {
    border-color: var(--red);
    color: var(--red);
}

.btn-secondary {
    background: var(--blue-light);
    color: white;
    border: none;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-secondary:hover {
    background: var(--blue);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
}

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 2.5rem 0;
    color: var(--text-muted);
    font-size: 0.825rem;
}

/* ============================================================
   Stats Section
   ============================================================ */
.stats-section {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.stats-section h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1.5rem;
    letter-spacing: -0.03em;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface-hover);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    text-align: center;
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: var(--blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-value {
    display: block;
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--blue);
    margin-bottom: 0.15rem;
    letter-spacing: -0.04em;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
}

.chart-card {
    background: var(--surface-hover);
    padding: 1.125rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.chart-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
    text-align: center;
    letter-spacing: -0.01em;
}

/* ============================================================
   Settings Section
   ============================================================ */
.settings-section {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.settings-section h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1.5rem;
    letter-spacing: -0.03em;
}

.settings-card {
    background: var(--surface-hover);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.25rem;
    border: 1px solid var(--border);
}

.settings-card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}

.settings-desc {
    font-size: 0.825rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.muscle-groups-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.muscle-tag {
    background: var(--blue);
    color: white;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.muscle-tag button {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    opacity: 0.75;
    transition: opacity var(--transition);
}

.muscle-tag button:hover {
    opacity: 1;
}

.setting-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

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

.setting-item label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.setting-item input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
    accent-color: var(--blue);
}

/* --- Timer --- */
.timer-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.timer-controls input {
    width: 100px;
    padding: 0.5rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition);
}

.timer-controls input:focus {
    outline: none;
    border-color: var(--blue);
}

.timer-display {
    font-size: 2rem;
    font-weight: 800;
    color: var(--blue);
    text-align: center;
    margin-top: 1rem;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.timer-display.hidden {
    display: none;
}

/* --- 1RM Calculator --- */
.rm-calculator {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rm-result {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--green);
    text-align: center;
    padding: 1rem;
    background: var(--surface-hover);
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
    border: 1px solid var(--border);
}

/* --- Utilities --- */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.hidden {
    display: none !important;
}

.chart-unavailable,
.text-muted {
    color: var(--text-muted);
    font-size: 0.875rem;
    text-align: center;
}

.pr-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.625rem;
}

.pr-card {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-hover);
    transition: all var(--transition);
}

.pr-card:hover {
    border-color: var(--blue);
}

.pr-card strong { color: var(--blue); }
.pr-card small { color: var(--text-muted); }

.weight-history {
    display: grid;
    gap: 0.4rem;
    margin-top: 1rem;
}

.weight-record {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.75rem;
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    gap: 0.5rem;
    transition: border-color var(--transition);
}

.weight-record:hover {
    border-color: var(--blue);
}

.weight-record-info {
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
    flex-wrap: wrap;
}

.weight-record-actions {
    display: flex;
    gap: 0.2rem;
    flex-shrink: 0;
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    color: var(--text-muted);
}

.icon-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* ============================================================
   Home Section
   ============================================================ */
.home-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.home-day-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 1.5rem 1rem;
    text-align: center;
}

.home-weekday {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
}

.home-date {
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.home-timer-card,
.home-weekly-card {
    margin-bottom: 0;
}

.home-day-card {
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    color: white;
    border-radius: var(--radius-xl);
    padding: 2.25rem 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    box-shadow: var(--shadow-md);
}

.home-weekday {
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: capitalize;
    letter-spacing: -0.03em;
}

.home-date {
    font-size: 0.95rem;
    opacity: 0.9;
    text-transform: capitalize;
}

.home-hint {
    margin-top: 0.75rem;
    font-size: 0.78rem;
    opacity: 0.85;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.home-timer-card,
.home-weekly-card {
    margin-bottom: 0;
}

.danger-zone .btn-reset {
    width: 100%;
}

.home-weekly-card {
    margin-bottom: 0;
}

.weekly-days {
    display: flex;
    justify-content: space-between;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.weekly-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.25rem;
    border-radius: var(--radius-md);
    flex: 1;
    transition: background 0.2s ease;
}

.weekly-day.today {
    background: var(--surface-hover);
}

.weekly-day-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.weekly-day-dot {
    font-size: 1.1rem;
    color: var(--text-muted);
    line-height: 1;
    transition: color 0.2s ease;
}

.weekly-day.trained .weekly-day-dot {
    color: var(--blue);
}

.weekly-day-num {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.weekly-summary-text {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

/* ============================================================
   Nutrition Section
   ============================================================ */
.nutrition-section {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.nutrition-section h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1.5rem;
    letter-spacing: -0.03em;
}

.nutrition-section .chart-card {
    margin: 1rem 0;
}

.weight-tracker {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* --- Calorie Calculator --- */
.calorie-calculator {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.calorie-result {
    display: none;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1rem;
    background: var(--surface-hover);
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
    border: 1px solid var(--border);
}

.calorie-result.visible {
    display: flex;
}

.calorie-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.calorie-result-row .label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.calorie-result-row .value {
    font-weight: 700;
    color: var(--blue);
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
}

.calorie-result-row.highlight .value {
    color: var(--green);
    font-size: 1.3rem;
}

/* ============================================================
   Bilbo (Strength Tier) Components
   ============================================================ */

/* --- Setup Screen --- */
.bilbo-setup {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.bilbo-setup-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    text-align: center;
    max-width: 380px;
    width: 100%;
    box-shadow: var(--shadow-md);
}

.bilbo-setup-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.bilbo-setup-card h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    margin-bottom: 0.15rem;
}

.bilbo-setup-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.bilbo-setup-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.bilbo-setup-weight {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.bilbo-weight-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--surface-hover);
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    display: grid;
    place-items: center;
    line-height: 1;
}

.bilbo-weight-btn:hover {
    background: var(--blue);
    color: white;
    border-color: var(--blue);
    transform: scale(1.08);
}

.bilbo-weight-btn:active {
    transform: scale(0.95);
}

.bilbo-weight-pick {
    display: flex;
    align-items: baseline;
    gap: 0.15rem;
}

.bilbo-weight-pick span:first-child {
    font-size: 3rem;
    font-weight: 900;
    color: #f97316;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
    min-width: 80px;
    text-align: center;
}

.bilbo-weight-pick-unit {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
}

.bilbo-setup-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* --- Setup Info Box --- */
.bilbo-setup-info {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.25rem;
    text-align: left;
}

.bilbo-setup-info p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.4rem;
}

.bilbo-setup-info p:last-child {
    margin-bottom: 0;
}

.bilbo-setup-info strong {
    color: var(--text);
}

/* --- 1RM Input --- */
.bilbo-setup-orm {
    margin-bottom: 1.25rem;
}

.bilbo-setup-orm label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-align: left;
}

.bilbo-orm-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bilbo-orm-row .input-field {
    flex: 1;
    margin-bottom: 0;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
}

.bilbo-orm-unit {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
}

.bilbo-orm-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    text-align: left;
    line-height: 1.5;
}

/* --- Divider --- */
.bilbo-setup-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.bilbo-setup-divider::before,
.bilbo-setup-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.bilbo-setup-divider span {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* --- Minimalistic Reps Entry --- */
.bilbo-reps-entry {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.bilbo-reps-big {
    display: flex;
    align-items: center;
    gap: 0;
}

.bilbo-reps-big input {
    width: 80px;
    height: 64px;
    border: none;
    border-bottom: 3px solid var(--blue);
    background: transparent;
    color: var(--text);
    font-size: 2.5rem;
    font-weight: 800;
    text-align: center;
    outline: none;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
}

.bilbo-reps-big input::-webkit-outer-spin-button,
.bilbo-reps-big input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.bilbo-reps-big input:focus {
    border-bottom-color: #f97316;
}

.bilbo-reps-big input::placeholder {
    color: var(--text-muted);
    font-weight: 600;
}

.bilbo-reps-adj {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--surface-hover);
    color: var(--text);
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    display: grid;
    place-items: center;
    line-height: 1;
    flex-shrink: 0;
}

.bilbo-reps-adj:hover {
    background: var(--blue);
    color: white;
    border-color: var(--blue);
    transform: scale(1.08);
}

.bilbo-reps-adj:active {
    transform: scale(0.92);
}

.bilbo-reps-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: -0.25rem;
}

.bilbo-log-btn {
    margin-top: 0.5rem;
    width: 100%;
}

.bilbo-start-btn {
    background: linear-gradient(135deg, #f97316, #ea580c) !important;
    font-size: 1rem !important;
    padding: 0.85rem 1.5rem !important;
    box-shadow: 0 4px 16px rgba(249, 115, 22, 0.35) !important;
}

.bilbo-start-btn:hover {
    background: linear-gradient(135deg, #ea580c, #dc2626) !important;
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.45) !important;
    transform: translateY(-1px);
}

/* --- Hero Card --- */
.bilbo-hero {
    background: linear-gradient(135deg, #f97316, #ea580c, #dc2626);
    border-radius: var(--radius-xl);
    padding: 2rem 1.5rem;
    text-align: center;
    color: white;
    box-shadow: 0 8px 32px rgba(249, 115, 22, 0.25);
    position: relative;
    overflow: hidden;
}

.bilbo-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.15) 0%, transparent 60%);
    pointer-events: none;
}

.bilbo-hero-sub {
    font-size: 0.85rem;
    opacity: 0.85;
    margin-top: 0.35rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.bilbo-weight-display {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 1.1;
    margin: 0.5rem 0 0.15rem;
    font-variant-numeric: tabular-nums;
}

.bilbo-weight-unit {
    font-size: 1.1rem;
    font-weight: 500;
    opacity: 0.75;
    margin-left: 0.15rem;
    vertical-align: super;
}

.bilbo-rep-target {
    font-size: 0.825rem;
    opacity: 0.8;
    margin-top: 0.25rem;
    font-weight: 500;
}

.bilbo-tier-badge {
    display: inline-block;
    padding: 0.3rem 0.9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.75rem;
    backdrop-filter: blur(4px);
}

/* --- Log Form --- */
.bilbo-log {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.bilbo-log .field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.bilbo-log .field label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bilbo-log .field input {
    padding: 0.65rem 0.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    background: var(--surface-hover);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    font-variant-numeric: tabular-nums;
}

.bilbo-log .field input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    background: var(--surface);
}

.bilbo-log .btn-log {
    background: var(--blue);
    color: white;
    border: none;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: -0.01em;
}

.bilbo-log .btn-log:hover {
    background: var(--blue-dark);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* --- History --- */
.bilbo-history {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.bilbo-history-header {
    padding: 1.25rem 1.5rem 0.75rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.bilbo-history-list {
    display: flex;
    flex-direction: column;
}

.bilbo-history-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border-light);
    transition: background var(--transition);
}

.bilbo-history-item:hover {
    background: var(--surface-hover);
}

.bilbo-history-date {
    font-size: 0.825rem;
    color: var(--text-muted);
    font-weight: 500;
}

.bilbo-history-weight {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.bilbo-history-reps {
    font-size: 0.825rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-align: right;
}

.bilbo-history-status {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
}

.bilbo-history-status.up {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

[data-theme="dark"] .bilbo-history-status.up {
    background: rgba(34, 197, 94, 0.18);
    color: #4ade80;
}

.bilbo-history-status.same {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

[data-theme="dark"] .bilbo-history-status.same {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
}

/* --- Stats Row --- */
.bilbo-history-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    border-top: 1px solid var(--border);
}

.bilbo-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem;
    gap: 0.15rem;
}

.bilbo-stat:not(:last-child) {
    border-right: 1px solid var(--border-light);
}

.bilbo-stat-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.bilbo-stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Progress Chart --- */
.bilbo-progress-chart {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

/* --- Section Wrapper --- */
.bilbo-section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
    .app-container {
        padding: 0.75rem;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .calendar-controls button,
    .calendar-controls .month-year {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }

    .view-btn {
        padding: 0.55rem;
        font-size: 0.78rem;
    }

    .calendar {
        gap: 0.2rem;
    }

    .weekday-header {
        font-size: 0.6rem;
    }

    .cardio-form-grid {
        grid-template-columns: 1fr;
    }

    .day-cell {
        min-height: 2.75rem;
        font-size: 0.78rem;
    }

    .week-day-cell {
        min-height: 4.25rem;
    }

    dialog {
        max-height: 90vh;
    }

    .bilbo-hero {
        padding: 1.5rem 1rem;
    }

    .bilbo-weight-display {
        font-size: 2.75rem;
    }

    .bilbo-setup-card {
        padding: 2rem 1.25rem;
    }

    .bilbo-weight-pick span:first-child {
        font-size: 2.5rem;
    }

    .bilbo-history-item {
        grid-template-columns: 1fr auto auto;
        padding: 0.65rem 1rem;
    }

    .bilbo-history-reps {
        display: none;
    }

    .bilbo-history-stats {
        grid-template-columns: repeat(3, 1fr);
    }

    .bilbo-stat-value {
        font-size: 1.1rem;
    }
}

@media (min-width: 768px) {
    .day-cell {
        font-size: 0.95rem;
    }

    .month-day-cell {
        min-height: 4.5rem;
    }
}

/* ============================================================
   Nutrition extensions
   ============================================================ */
.nutrition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.nutrition-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.meal-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0;
}
.macro-pill {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.meal-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: var(--surface-hover);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}
.meal-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.meals-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.75rem;
    max-height: 35vh;
    overflow-y: auto;
}

.water-tracker {
    background: linear-gradient(135deg, #38bdf8, #2563eb);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    color: white;
    margin-bottom: 0.75rem;
}
.water-display {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}
.water-count {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
    transition: transform 0.15s ease, color 0.15s ease;
}
.water-label {
    font-size: 0.95rem;
    opacity: 0.85;
}
.water-bar {
    height: 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.2);
    overflow: hidden;
    margin-bottom: 0.5rem;
}
.water-bar-fill {
    height: 100%;
    background: white;
    border-radius: 999px;
    transition: width 0.2s ease;
}
.water-presets {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.water-preset-btn {
    flex: 1;
    min-width: 70px;
    padding: 0.5rem 0.75rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.water-preset-btn:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.6);
    transform: translateY(-1px);
}
.water-preset-btn:active {
    background: rgba(255,255,255,0.4);
    transform: scale(0.97);
}

/* --- Minimal water and workout history --- */
.water-tracker {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: none;
    padding: 1.1rem;
}
.water-display { justify-content: space-between; margin-bottom: 0.85rem; }
.water-count { font-size: 2rem; color: var(--text); }
.water-label { color: var(--text-muted); opacity: 1; }
.water-progress { color: var(--text-muted); font-size: 0.8rem; font-weight: 700; }
.water-bar { height: 6px; background: var(--surface-hover); margin-bottom: 0.85rem; }
.water-bar-fill { display: block; background: #38bdf8; }
.water-presets { margin: 0; }
.water-preset-btn { min-width: 0; background: var(--surface-hover); color: var(--text-secondary); border: 1px solid var(--border); }
.water-preset-btn:hover { background: var(--surface); border-color: #38bdf8; color: #0284c7; transform: none; }
.water-hint { margin: 0.65rem 0 0; text-align: center; color: var(--text-muted); font-size: 0.72rem; }
.water-custom { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; margin-top: 0.65rem; }.water-custom input { min-width: 0; padding: 0.55rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--text); }.water-custom button { border: 0; border-radius: var(--radius-md); background: var(--blue); color: white; padding: 0.55rem 0.75rem; font-weight: 700; cursor: pointer; }
.history-section { display: flex; flex-direction: column; gap: 1rem; }
.history-toolbar { display: flex; flex-direction: column; gap: 0.65rem; }
.history-filters { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.15rem; }
.history-filter-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); border-radius: 999px; padding: 0.35rem 0.7rem; white-space: nowrap; font-size: 0.78rem; cursor: pointer; }
.history-filter-btn.active { color: var(--text); background: var(--surface-hover); border-color: var(--text-muted); }
.filter-divider { display: none; }
.workout-history-list { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.history-item { display: grid; grid-template-columns: 4.4rem 1fr 2rem; align-items: center; gap: 0.75rem; padding: 0.9rem 0.1rem; border-bottom: 1px solid var(--border); }
.history-date { display: flex; flex-direction: column; text-transform: capitalize; }
.history-date strong { font-size: 0.9rem; }
.history-date small, .history-summary p { margin: 0; color: var(--text-muted); font-size: 0.76rem; }
.history-summary { min-width: 0; }
.history-summary p { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-meta { display: flex; gap: 0.35rem; margin-top: 0.3rem; }
.history-meta span { font-size: 0.68rem; color: var(--text-muted); }
.history-open-btn { border: 0; background: transparent; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; }
.history-calendar-header { display: grid; grid-template-columns: 2rem 1fr 2rem; align-items: center; text-align: center; padding: 0.25rem 0 0.85rem; text-transform: capitalize; }
.history-month-btn { width: 2rem; height: 2rem; border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary); font-size: 1.45rem; cursor: pointer; }
.history-month-btn:hover { background: var(--surface-hover); }
.history-calendar-weekdays, .history-calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.3rem; }
.history-calendar-weekdays { margin-bottom: 0.25rem; color: var(--text-muted); font-size: 0.7rem; font-weight: 700; text-align: center; }
.history-calendar-day, .history-calendar-empty { min-height: 2.8rem; border-radius: var(--radius-md); }
.history-calendar-day { position: relative; border: 1px solid transparent; background: transparent; color: var(--text-secondary); cursor: pointer; font: inherit; }
.history-calendar-day:hover { background: var(--surface-hover); border-color: var(--border); }
.history-calendar-day.has-entry { color: var(--text); font-weight: 700; background: var(--surface-hover); }
.history-calendar-marker { position: absolute; bottom: 0.35rem; left: 50%; width: 0.28rem; height: 0.28rem; border-radius: 50%; background: #2563eb; transform: translateX(-50%); }
.history-calendar-marker.cardio { background: #f97316; }

.active-workout-launch { width: 100%; padding: 0.9rem; font-size: 1rem; }
.active-workout-modal { width: min(760px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; background: var(--background); }
.active-workout-header { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; padding: 1.25rem; background: var(--background); border-bottom: 1px solid var(--border); }
.active-workout-header span { font-size: 0.68rem; font-weight: 800; color: var(--blue); letter-spacing: 0.1em; }
.active-workout-header h2 { margin: 0.25rem 0 0; font-size: 1.15rem; text-transform: capitalize; }
.active-workout-list { padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.active-exercise { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem; }
.active-exercise h3 { margin: 0 0 0.8rem; font-size: 1.05rem; }.active-exercise h3 small { display: block; margin-top: 0.2rem; color: var(--blue); font-size: 0.75rem; }
.active-sets { display: flex; flex-direction: column; gap: 0.5rem; }.active-set { display: grid; grid-template-columns: 2rem 1fr 1fr; gap: 0.5rem; align-items: center; }.active-set span { color: var(--text-muted); font-weight: 700; text-align: center; }.active-set input { min-width: 0; padding: 0.8rem; font-size: 1.05rem; }
.active-add-set { width: 100%; margin-top: 0.7rem; border: 1px dashed var(--blue); background: transparent; color: var(--blue); border-radius: var(--radius-md); padding: 0.7rem; font-weight: 700; cursor: pointer; }
.backup-setting { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem; }.backup-setting small { color: var(--text-muted); font-size: 0.75rem; }
.photos-gallery { display: block; }.photo-carousel { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) 2.5rem; align-items: center; gap: 0.5rem; }.photo-carousel-main { margin: 0; min-width: 0; text-align: center; }.photo-carousel-main img { display: block; width: 100%; height: min(42vh, 300px); object-fit: contain; border-radius: var(--radius-lg); background: var(--surface-hover); }.photo-carousel-main figcaption { margin-top: 0.5rem; color: var(--text-muted); font-size: 0.8rem; }.photo-carousel-nav { width: 2.25rem; height: 2.25rem; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text); font-size: 1.5rem; cursor: pointer; }.photo-carousel-dots { display: flex; justify-content: center; gap: 0.35rem; margin-top: 0.75rem; }.photo-carousel-dots button { min-height: 0; width: 0.5rem; height: 0.5rem; padding: 0; border: 0; border-radius: 50%; background: var(--border); cursor: pointer; }.photo-carousel-dots button.active { width: 1.25rem; border-radius: 999px; background: var(--blue); }
.weekly-goals { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }.goal-item { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.65rem; border-radius: var(--radius-md); background: var(--surface-hover); }.goal-item strong { font-size: 1.05rem; }.goal-item span { color: var(--text-muted); font-size: 0.72rem; }.goal-item i { height: 4px; overflow: hidden; border-radius: 99px; background: var(--border); }.goal-item b { display: block; height: 100%; background: var(--blue); }
button, .btn-primary, .btn-secondary, .btn-cancel, .btn-icon { min-height: 2.75rem; } :focus-visible { outline: 3px solid #60a5fa; outline-offset: 2px; }
.auth-modal { width: min(380px, calc(100vw - 2rem)); border-radius: var(--radius-xl); background: var(--surface); }.auth-modal form { display: flex; flex-direction: column; gap: 0.75rem; padding: 1.75rem; }.auth-brand { color: var(--blue); font-weight: 800; letter-spacing: -0.04em; font-size: 1.35rem; }.auth-modal h2 { margin: 0; }.auth-error { min-height: 1.2rem; margin: 0; color: var(--red); font-size: 0.82rem; }.authorized-users { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.75rem 0; }.authorized-user { display: flex; align-items: center; justify-content: space-between; padding: 0.55rem 0.7rem; border-radius: var(--radius-md); background: var(--surface-hover); }.authorized-user button { border: 0; background: transparent; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; }.header-user { color: var(--text-muted); font-size: 0.82rem; font-weight: 700; }

/* Water presets in regular settings card (light theme) */
.settings-card .water-presets {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.settings-card .water-preset-btn {
    flex: 1;
    min-width: 70px;
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.settings-card .water-preset-btn:hover {
    border-color: var(--blue);
    background: var(--blue);
    color: white;
    transform: translateY(-1px);
}
.settings-card .water-preset-btn:active {
    background: var(--blue-dark);
    transform: scale(0.97);
}
.settings-card .water-hint {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.water-count-animate {
    animation: waterCountPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.water-bar-animate {
    animation: waterBarGrow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes waterCountPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.25); color: #22c55e; }
    100% { transform: scale(1); }
}

@keyframes waterBarGrow {
    from { width: 0; }
}

.measurements-history {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.75rem;
    max-height: 35vh;
    overflow-y: auto;
}
.measurement-record {
    padding: 0.6rem 0.75rem;
    background: var(--surface-hover);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.measurement-values {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.photo-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
}
.photo-row .input-field {
    margin-bottom: 0;
}
.photos-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}
.photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}
.photo-card {
    background: var(--surface-hover);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}
.photo-card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}
.photo-card figcaption {
    padding: 0.5rem 0.65rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Carrusel de fotos: estas reglas van después de la galería clásica. */
#photosGallery.photos-gallery { display: block; width: 100%; }
#photosGallery .photo-carousel { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) 2.5rem; align-items: center; width: 100%; gap: 0.5rem; }
#photosGallery .photo-carousel-main { margin: 0; min-width: 0; width: 100%; }
#photosGallery .photo-carousel-main img { display: block; width: 100%; height: clamp(180px, 38vh, 280px); object-fit: contain; background: var(--surface-hover); border: 1px solid var(--border); border-radius: var(--radius-lg); }
#photosGallery .photo-carousel-dots { display: flex; width: 100%; justify-content: center; gap: 0.35rem; margin-top: 0.75rem; }
@media (max-width: 420px) { #photosGallery .photo-carousel { grid-template-columns: 2rem minmax(0, 1fr) 2rem; gap: 0.25rem; } #photosGallery .photo-carousel-nav { width: 2rem; height: 2rem; } }

.month-compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.compare-col {
    background: var(--surface-hover);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 0.75rem;
}
.compare-title {
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}
.compare-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    padding: 0.2rem 0;
}
.compare-delta {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: right;
}
.routine-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.btn-sm {
    width: auto;
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
}
.tech-dialog {
    border: none;
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 1.5rem 1.5rem 1.25rem;
    max-width: 480px;
    width: calc(100% - 3rem);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    text-align: center;
}

.tech-dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
}

.tech-video-container {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin: 0.75rem 0 0.5rem;
    background: #000;
}

.tech-video-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.tech-popup-name {
    display: block;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--blue);
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.tech-popup-tip {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 1rem;
}

.tech-popup-hint {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.25rem;
}

/* --- Routine Modal --- */
.routine-exercises-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    max-height: 30vh;
    overflow-y: auto;
}

.routine-exercise-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.6rem 0.75rem;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.routine-exercise-item select {
    flex: 1;
    padding: 0.5rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text);
}

.routine-exercise-item input[type="number"] {
    width: 70px;
    padding: 0.5rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text);
}

.routine-exercise-item .remove-btn {
    background: transparent;
    border: none;
    color: var(--red);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.routine-exercise-item .remove-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

.routine-apply-exercises { display: flex; flex-direction: column; gap: 0.75rem; max-height: 50vh; overflow-y: auto; }
.routine-apply-row { padding: 0.85rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-hover); }
.routine-apply-row h3 { margin: 0 0 0.65rem; font-size: 0.95rem; }
.routine-muscle-select { width: 100%; margin-bottom: 0.6rem; }
.routine-series-list { display: flex; flex-direction: column; gap: 0.45rem; }
.routine-series-row { display: grid; grid-template-columns: 4.2rem 1fr 1fr 2rem; align-items: center; gap: 0.45rem; }
.routine-series-row span { color: var(--text-muted); font-size: 0.8rem; font-weight: 700; }
.remove-routine-series { border: 0; background: transparent; color: var(--text-muted); font-size: 1.25rem; cursor: pointer; }
.remove-routine-series:hover { color: var(--red); }
.add-routine-series { width: 100%; margin-top: 0.6rem; padding: 0.5rem; border: 1px dashed var(--border); border-radius: var(--radius-md); background: transparent; color: var(--blue); font-weight: 700; cursor: pointer; }
.add-routine-series:hover { border-color: var(--blue); background: var(--surface); }
@media (max-width: 640px) { .routine-series-row { grid-template-columns: 3.8rem 1fr 1fr 1.75rem; gap: 0.3rem; } }

#routineModal {
    max-width: 520px;
    width: calc(100% - 2rem);
}


.routine-quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    flex: 1;
    min-width: 140px;
    justify-content: center;
}

.routine-quick-btn:hover {
    border-color: var(--routine-color);
    background: var(--routine-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.routine-quick-icon {
    font-size: 1rem;
}

/* --- Routines Section Cards --- */
.routine-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
}

.routine-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--routine-color);
}

.routine-card:hover {
    border-color: var(--routine-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.routine-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.routine-card-header h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.routine-badge {
    background: var(--routine-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.routine-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.routine-exercises-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.routine-ex-tag {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.6rem;
    font-size: 0.725rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.routine-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.routine-actions .btn-sm {
    width: auto;
    padding: 0.5rem 0.85rem;
    font-size: 0.825rem;
}

/* ============================================================
   FamilyGYM 2.0 — Editorial dashboard refresh
   These rules intentionally live last so every existing feature keeps its IDs
   and behaviour while the whole interface receives the new visual system.
   ============================================================ */
:root {
    --ink: #15223b;
    --navy: #101b32;
    --accent: #7c5cff;
    --accent-2: #35c5b7;
    --canvas: #f3f5fb;
    --card-shadow: 0 14px 35px rgba(25, 37, 65, .08);
}

body {
    background:
        radial-gradient(circle at 5% -5%, rgba(124, 92, 255, .14), transparent 31rem),
        radial-gradient(circle at 96% 3%, rgba(53, 197, 183, .10), transparent 26rem),
        var(--canvas);
    color: var(--ink);
}

[data-theme="dark"] body {
    --canvas: #0b1020;
    --ink: #eaf0ff;
    --card-shadow: 0 18px 42px rgba(0, 0, 0, .25);
}

.app-container {
    max-width: 1180px;
    padding: 1.5rem clamp(1rem, 3vw, 2.75rem) 3rem;
}

.header {
    min-height: 76px;
    margin: 0 0 1rem;
    padding: .8rem 1rem;
    border: 1px solid color-mix(in srgb, var(--border) 78%, white);
    border-radius: 22px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(14px);
}

.header-brand { display: flex; align-items: center; gap: .8rem; }
.brand-mark {
    width: 42px; height: 42px; display: grid; place-items: center;
    border-radius: 14px; color: white; font-weight: 800; letter-spacing: -.08em;
    background: linear-gradient(135deg, var(--accent), #496cff 70%);
    box-shadow: 0 8px 18px rgba(92, 81, 235, .28);
}
.brand-kicker { margin: 0 0 .08rem; color: var(--text-muted); font-size: .62rem; font-weight: 800; letter-spacing: .16em; }
.header h1 { font-size: 1.3rem; letter-spacing: -.055em; line-height: 1; }
.header-actions { gap: .75rem; }
.header-status { display: inline-flex; align-items: center; gap: .45rem; color: var(--text-secondary); font-size: .79rem; font-weight: 700; }
.header-status i { width: .5rem; height: .5rem; display: inline-block; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-2) 18%, transparent); }
.header .btn-icon { width: 42px; height: 42px; padding: 0; display: grid; place-items: center; border-radius: 13px; background: var(--surface-hover); }

.main-nav {
    position: sticky; top: .75rem; z-index: 20; margin: 0 0 2rem;
    padding: .45rem; gap: .25rem; overflow-x: auto; scrollbar-width: none;
    border: 1px solid color-mix(in srgb, var(--border) 80%, white);
    border-radius: 18px; background: color-mix(in srgb, var(--surface) 90%, transparent);
    box-shadow: 0 8px 25px rgba(24, 36, 65, .06); backdrop-filter: blur(16px);
}
.main-nav::-webkit-scrollbar { display: none; }
.nav-btn {
    position: relative; flex: 1 0 max-content; padding: .72rem .85rem; border: 0; border-radius: 12px;
    background: transparent; color: var(--text-muted); font-weight: 750; font-size: .79rem; letter-spacing: -.01em;
}
.nav-btn:hover { background: var(--surface-hover); color: var(--text); transform: none; }
.nav-btn.active { color: white; background: linear-gradient(135deg, var(--accent), #5271ff); box-shadow: 0 6px 14px rgba(91, 78, 238, .23); }
.nav-indicator { display: none !important; }

.section { animation: section-rise .35s ease both; }
@keyframes section-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.section h2 { font-size: clamp(1.45rem, 3vw, 2rem); letter-spacing: -.055em; color: var(--ink); }
.section h3 { letter-spacing: -.035em; }

.settings-card, .card, .routine-card, .home-day-card, .history-item, .workout-card,
.bilbo-setup-card, .bilbo-hero, .calendar-section, .stats-summary {
    border: 1px solid color-mix(in srgb, var(--border) 88%, white);
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    background: color-mix(in srgb, var(--surface) 96%, transparent);
}
.settings-card, .card { padding: clamp(1rem, 2.3vw, 1.45rem); }
.settings-card:hover, .card:hover, .routine-card:hover { transform: translateY(-2px); box-shadow: 0 18px 38px rgba(25, 37, 65, .12); }

.home-section { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(260px, .8fr); gap: 1.2rem; align-items: start; }
.home-day-card {
    grid-row: span 2; min-height: 330px; padding: 2rem; overflow: hidden; position: relative;
    color: white; border: 0; background: linear-gradient(145deg, #131d39, #273d88 60%, #7b5cf5);
}
.home-day-card::before { content: ''; position: absolute; width: 22rem; height: 22rem; border-radius: 50%; right: -10rem; bottom: -12rem; background: rgba(110, 235, 220, .22); }
.home-day-card::after { content: 'MOVE'; position: absolute; right: 1.5rem; bottom: 1rem; color: rgba(255,255,255,.14); font-size: clamp(3rem, 10vw, 6.5rem); font-weight: 900; letter-spacing: -.1em; }
.home-day-header { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: .6rem; }
.home-weekday { padding: .35rem .65rem; border-radius: 999px; background: rgba(255,255,255,.16); font-size: .7rem; font-weight: 800; letter-spacing: .1em; }
.home-date { font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 800; letter-spacing: -.075em; }
.home-timer-card, .home-weekly-card { margin: 0 !important; }

.section-header { margin-bottom: 1.2rem; align-items: center; }
.section-actions { display: flex; gap: .5rem; }
.btn-primary, .btn-secondary, .btn-sm {
    border: 0; border-radius: 12px; font-weight: 800; letter-spacing: -.015em;
    box-shadow: none; transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), #5071ff); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 9px 18px rgba(91, 78, 238, .26); filter: brightness(1.04); }
.btn-secondary { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); }
.input-field, input[type="number"], input[type="search"], select, textarea {
    min-height: 44px; border: 1px solid var(--border); border-radius: 12px;
    background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.4);
}
.input-field:focus, input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid color-mix(in srgb, var(--accent) 16%, transparent); }

.history-toolbar, .history-view-toggle, .calendar-controls { padding: .6rem; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.history-filter-btn, .view-btn, .history-view-btn { border-radius: 10px; font-weight: 750; }
.history-filter-btn.active, .view-btn.active, .history-view-btn.active { color: white; background: var(--accent); border-color: var(--accent); }
.calendar { padding: .65rem; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--card-shadow); }
.calendar-day { border-radius: 12px !important; }
.calendar-day:hover { background: color-mix(in srgb, var(--accent) 10%, var(--surface-hover)); }

.stats-summary { padding: 1rem; gap: .75rem; }
.stat-card { border-radius: 14px; background: var(--surface-hover); padding: 1rem; }
.stat-value { color: var(--accent); font-weight: 850; letter-spacing: -.055em; }
.routine-card { border-radius: 18px; }
.routine-card::before { height: 5px; background: linear-gradient(90deg, var(--routine-color), color-mix(in srgb, var(--routine-color) 35%, white)); }

.footer { margin-top: 2.5rem; border: 0; color: var(--text-muted); }

@media (max-width: 760px) {
    .app-container { padding: .8rem .85rem 2.25rem; }
    .header { min-height: 64px; padding: .65rem .75rem; border-radius: 17px; }
    .brand-mark { width: 36px; height: 36px; border-radius: 11px; font-size: .8rem; }
    .header h1 { font-size: 1.1rem; }
    .header-status { display: none; }
    .main-nav { top: .35rem; margin-bottom: 1.25rem; border-radius: 14px; }
    .nav-btn { flex: 0 0 auto; padding: .65rem .75rem; font-size: .72rem; }
    .home-section { grid-template-columns: 1fr; }
    .home-day-card { grid-row: auto; min-height: 220px; padding: 1.4rem; }
    .section-header { align-items: flex-start; flex-direction: column; }
    .section-actions, .section-actions > * { width: 100%; }
    .settings-card, .card { border-radius: 16px; }
    .history-toolbar { padding: .45rem; }
}

/* --- Motion & colour pass: energetic, but still calm enough for daily use --- */
:root {
    --accent: #0f9f90;
    --accent-2: #ff9d4d;
    --blue: #1685d1;
    --blue-dark: #0d68ae;
    --blue-light: #69c7ff;
    --green: #16b899;
    --canvas: #f3f8f8;
}
[data-theme="dark"] {
    --accent: #31d3bd;
    --accent-2: #ffad66;
    --blue: #43b7ff;
    --blue-dark: #188fd7;
    --canvas: #091518;
}

body {
    background:
        radial-gradient(circle at -6% -7%, rgba(15, 159, 144, .18), transparent 29rem),
        radial-gradient(circle at 104% 2%, rgba(255, 157, 77, .15), transparent 25rem),
        radial-gradient(circle at 52% 105%, rgba(22, 133, 209, .10), transparent 32rem),
        var(--canvas);
}

.brand-mark {
    background: linear-gradient(145deg, #0f9f90, #1685d1 72%);
    animation: brand-breathe 4.5s ease-in-out infinite;
}
.nav-btn.active { background: linear-gradient(135deg, #0f9f90, #1685d1); animation: active-tab .42s cubic-bezier(.2,.9,.25,1.25) both; }
.home-day-card { background: linear-gradient(145deg, #0a2940, #116d8c 58%, #159b8f); }
.home-day-card::before { background: rgba(255, 181, 104, .22); animation: orb-drift 9s ease-in-out infinite alternate; }
.home-day-card::after { animation: word-fade 5s ease-in-out infinite; }
.btn-primary { background: linear-gradient(135deg, #0f9f90, #1685d1); position: relative; overflow: hidden; }
.btn-primary::after { content: ''; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 28%, rgba(255,255,255,.26) 46%, transparent 64%); transform: translateX(-115%); transition: transform .5s ease; }
.btn-primary:hover::after { transform: translateX(115%); }
.btn-secondary { color: #087d72; background: rgba(15, 159, 144, .09); border-color: rgba(15, 159, 144, .25); }
[data-theme="dark"] .btn-secondary { color: #70eadb; }

.settings-card, .card, .routine-card, .history-item, .workout-card, .stat-card { transition: transform .24s cubic-bezier(.2,.8,.2,1), box-shadow .24s ease, border-color .24s ease, background .24s ease; }
.settings-card:hover, .card:hover, .routine-card:hover, .history-item:hover, .workout-card:hover { border-color: color-mix(in srgb, var(--accent) 36%, var(--border)); }
.stat-card { position: relative; overflow: hidden; }
.stat-card::after { content: ''; position: absolute; width: 6rem; height: 6rem; right: -2.4rem; bottom: -3.4rem; border-radius: 50%; background: color-mix(in srgb, var(--accent) 11%, transparent); transition: transform .35s ease; }
.stat-card:hover::after { transform: scale(1.35); }
.stat-card:nth-child(2n)::after { background: color-mix(in srgb, var(--accent-2) 15%, transparent); }

.section.active .settings-card, .section.active .card, .section.active .routine-card, .section.active .stat-card {
    animation: card-arrive .5s cubic-bezier(.2,.82,.28,1) both;
}
.section.active .settings-card:nth-of-type(2), .section.active .card:nth-of-type(2), .section.active .routine-card:nth-of-type(2) { animation-delay: .06s; }
.section.active .settings-card:nth-of-type(3), .section.active .card:nth-of-type(3), .section.active .routine-card:nth-of-type(3) { animation-delay: .12s; }
.section.active .settings-card:nth-of-type(4), .section.active .card:nth-of-type(4), .section.active .routine-card:nth-of-type(4) { animation-delay: .18s; }

.calendar-day { transition: transform .18s ease, background .18s ease, box-shadow .18s ease !important; }
.calendar-day:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 6px 14px rgba(15, 105, 125, .12); }
.routine-card::before { background: linear-gradient(90deg, var(--routine-color), var(--accent), transparent); }
.header-status i { animation: online-pulse 2.4s ease-in-out infinite; }

@keyframes card-arrive { from { opacity: 0; transform: translateY(15px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes active-tab { from { transform: scale(.86); opacity: .4; } to { transform: scale(1); opacity: 1; } }
@keyframes brand-breathe { 0%, 100% { transform: translateY(0); box-shadow: 0 8px 18px rgba(15, 159, 144, .25); } 50% { transform: translateY(-2px); box-shadow: 0 13px 25px rgba(22, 133, 209, .3); } }
@keyframes orb-drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(-24px, -20px) scale(1.14); } }
@keyframes word-fade { 0%, 100% { opacity: .11; } 50% { opacity: .19; } }
@keyframes online-pulse { 0%, 100% { box-shadow: 0 0 0 4px rgba(22, 184, 153, .16); } 50% { box-shadow: 0 0 0 7px rgba(22, 184, 153, .04); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Directional page navigation: the order in the top bar controls the motion. */
.section.active.section-enter-from-right {
    transform-origin: center;
    will-change: transform, opacity;
    animation: section-slide-from-right .46s cubic-bezier(.18,.86,.24,1) both;
}
.section.active.section-enter-from-left {
    transform-origin: center;
    will-change: transform, opacity;
    animation: section-slide-from-left .46s cubic-bezier(.18,.86,.24,1) both;
}
@keyframes section-slide-from-right {
    from { opacity: 0; transform: translateX(44px) scale(.985); filter: blur(2px); }
    to { opacity: 1; transform: translateX(0) scale(1); filter: blur(0); }
}
@keyframes section-slide-from-left {
    from { opacity: 0; transform: translateX(-44px) scale(.985); filter: blur(2px); }
    to { opacity: 1; transform: translateX(0) scale(1); filter: blur(0); }
}

/* Home dashboard — information-rich, with a clear next action. */
.home-section { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1.1rem; }
.home-day-card { grid-column: span 8; grid-row: auto; min-height: 320px; display: flex; align-items: stretch; }
.home-timer-card { grid-column: span 4; display: flex; flex-direction: column; justify-content: center; }
.home-weekly-card { grid-column: span 7; }
.home-quick-card { grid-column: span 5; }
.home-day-header { width: 100%; justify-content: center; }
.home-greeting { font-size: clamp(1.65rem, 4vw, 2.8rem); font-weight: 850; line-height: 1; letter-spacing: -.07em; }
.home-date { font-size: 1.05rem; font-weight: 600; letter-spacing: -.03em; opacity: .8; }
.home-hero-message { max-width: 27rem; margin: .55rem 0 1.25rem; color: rgba(255,255,255,.82); font-size: .98rem; }
.home-hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: auto; }
.home-hero-btn, .home-ghost-btn { min-height: 42px; border-radius: 12px; padding: .65rem .85rem; font: inherit; font-size: .82rem; font-weight: 800; cursor: pointer; transition: transform .2s ease, background .2s ease; }
.home-hero-btn { border: 0; color: #0b4b54; background: #e8fff8; }
.home-hero-btn span { margin-left: .35rem; font-size: 1rem; }
.home-ghost-btn { color: white; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.1); }
.home-hero-btn:hover, .home-ghost-btn:hover { transform: translateY(-2px); }
.home-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.home-card-heading h3 { margin: .12rem 0 0; font-size: 1.05rem; }
.eyebrow { color: var(--accent); font-size: .63rem; font-weight: 850; letter-spacing: .13em; }
.home-card-icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 10px; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.home-timer-card h3 { margin-bottom: .85rem; }
.home-timer-card .timer-controls { padding: .65rem; border-radius: 13px; background: var(--surface-hover); }
.home-timer-card .timer-controls input { width: 5.2rem; background: var(--surface); }
.home-timer-card .btn-primary { width: 100%; }
.home-quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; }
.home-quick-btn { min-height: 104px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: .7rem; padding: .75rem; border: 1px solid var(--border); border-radius: 14px; color: var(--text); background: var(--surface-hover); text-align: left; font: inherit; font-size: .75rem; font-weight: 750; cursor: pointer; transition: transform .2s ease, border-color .2s ease, background .2s ease; }
.home-quick-btn:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 42%, var(--border)); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.home-quick-icon { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 9px; color: white; background: linear-gradient(135deg, var(--accent), var(--blue)); font-size: 1.05rem; }
.weekly-summary-text { margin-top: .8rem; text-align: left; }

@media (max-width: 860px) {
    .home-day-card { grid-column: span 12; }
    .home-timer-card, .home-weekly-card { grid-column: span 6; }
    .home-quick-card { grid-column: span 12; }
}
@media (max-width: 560px) {
    .home-section { display: grid; grid-template-columns: 1fr; }
    .home-day-card, .home-timer-card, .home-weekly-card, .home-quick-card { grid-column: auto; }
    .home-day-card { min-height: 340px; }
    .home-quick-grid { grid-template-columns: 1fr; }
    .home-quick-btn { min-height: 64px; flex-direction: row; align-items: center; justify-content: flex-start; }
}

/* Final shared language for confirmations and empty sections. */
.app-toast { position: fixed; z-index: 1000; left: 50%; bottom: 1.25rem; width: min(420px, calc(100vw - 2rem)); padding: .85rem 1rem; border-radius: 14px; color: white; background: #143b4a; box-shadow: 0 14px 35px rgba(0,0,0,.22); font-weight: 750; text-align: center; opacity: 0; transform: translate(-50%, 1.25rem); pointer-events: none; transition: opacity .24s ease, transform .24s ease; }
.app-toast.visible { opacity: 1; transform: translate(-50%, 0); }
.app-toast[data-type="warning"] { background: #a85f16; }
.app-toast[data-type="error"] { background: #b43c4b; }
.empty-state { min-height: 124px; display: grid; place-items: center; align-content: center; gap: .45rem; padding: 1rem; border: 1px dashed var(--border); border-radius: 14px; color: var(--text-muted); text-align: center; }
.empty-state span { font-size: 1.55rem; filter: saturate(.8); }
.empty-state p { margin: 0; font-size: .83rem; font-weight: 650; }
.empty-state.compact { min-height: 76px; grid-template-columns: auto 1fr; justify-content: start; text-align: left; }
.routines-list > .text-muted, .workout-history-list > .text-muted { min-height: 124px; display: grid; place-items: center; border: 1px dashed var(--border); border-radius: 14px; text-align: center; }

.home-progress-card { grid-column: span 7; }
.home-tip-card { grid-column: span 5; display: flex; flex-direction: column; align-items: flex-start; gap: .65rem; padding: 1.25rem; overflow: hidden; position: relative; border: 1px solid rgba(22, 133, 209, .2); border-radius: 20px; color: #eaffff; background: linear-gradient(145deg, #123753, #176c82); box-shadow: var(--card-shadow); }
.home-tip-card::after { content: ''; position: absolute; right: -2.3rem; bottom: -3.2rem; width: 10rem; height: 10rem; border-radius: 50%; background: rgba(255, 178, 91, .2); }
.home-tip-card > * { position: relative; z-index: 1; }
.home-tip-card .eyebrow { color: #8ff7e3; }
.home-tip-card h3 { margin: .18rem 0 .38rem; font-size: 1.08rem; color: white; }
.home-tip-card p { margin: 0; color: rgba(234,255,255,.76); font-size: .82rem; line-height: 1.5; }
.home-tip-symbol { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 10px; color: #0f6574; background: #d8fff6; }
.home-tip-link { margin-top: auto; padding: 0; border: 0; color: white; background: transparent; font: inherit; font-size: .78rem; font-weight: 800; cursor: pointer; }
.home-tip-link span { margin-left: .25rem; font-size: 1rem; }
.home-progress-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; }
.home-progress-item { min-height: 96px; display: flex; flex-direction: column; justify-content: center; padding: .75rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-hover); }
.home-progress-label { margin-bottom: .35rem; color: var(--text-muted); font-size: .67rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.home-progress-item strong { overflow: hidden; color: var(--text); font-size: clamp(1rem, 2vw, 1.35rem); letter-spacing: -.055em; text-overflow: ellipsis; white-space: nowrap; }
.home-progress-item small { margin-top: .25rem; color: var(--text-muted); font-size: .68rem; }
@media (max-width: 860px) { .home-progress-card, .home-tip-card { grid-column: span 12; } }
@media (max-width: 560px) { .home-progress-grid { grid-template-columns: 1fr; } .home-progress-item { min-height: 74px; } }

/* Cleaner home layout: fewer elements, more breathing room. */
.home-section { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1.35rem; }
.home-day-card { grid-column: span 7; min-height: 295px; padding: clamp(1.45rem, 3vw, 2.25rem); }
.home-timer-card { grid-column: span 5; }
.home-weekly-card { grid-column: span 7; }
.home-quick-card { grid-column: span 5; }
.home-day-header { align-items: flex-start; }
.home-hero-message { max-width: 24rem; margin: .7rem 0 1.5rem; font-size: 1.02rem; }
.home-hero-actions { margin-bottom: 1rem; }
.home-hero-signoff { margin-top: auto; color: rgba(255,255,255,.58); font-size: .72rem; font-weight: 700; letter-spacing: .02em; }
.home-quick-grid { grid-template-columns: 1fr; gap: .5rem; }
.home-quick-btn { min-height: 55px; flex-direction: row; align-items: center; justify-content: flex-start; }
.home-weekly-card, .home-quick-card, .home-timer-card { min-height: 0; }

/* Each Bilbo block is visually independent: no more cards touching each other. */
.bilbo-section, .bilbo-content { display: flex; flex-direction: column; gap: 1.35rem; }
.bilbo-content .card, .bilbo-content .bilbo-hero, .bilbo-setup-card { margin: 0 !important; }
.bilbo-setup { padding: .35rem 0; }
.bilbo-setup-card { padding: clamp(1.25rem, 3vw, 2rem); }
.bilbo-hero { margin-bottom: 0; }
.bilbo-history-header { margin-bottom: .8rem; }
.bilbo-content .card h3 { margin-bottom: .85rem; }

@media (max-width: 860px) {
    .home-day-card { grid-column: span 12; }
    .home-timer-card, .home-weekly-card, .home-quick-card { grid-column: span 6; }
}
@media (max-width: 560px) {
    .home-section { display: grid; grid-template-columns: 1fr; gap: 1rem; }
    .home-day-card, .home-timer-card, .home-weekly-card, .home-quick-card { grid-column: auto; }
    .home-day-card { min-height: 275px; }
}
