/* Chalkboard Fitness — dark glassmorphic identity, phone-first layout. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --bg-main: #0b0f19;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(31, 41, 55, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);

    --color-violet: #7c3aed;
    --color-cyan: #06b6d4;
    --color-emerald: #10b981;
    --color-rose: #f43f5e;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --font-header: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --touch: 44px; /* minimum touch target */
}

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

body {
    background-color: var(--bg-main);
    background-image:
        radial-gradient(at 0% 0%, rgba(124, 58, 237, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
}

body.modal-open { overflow: hidden; }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-header);
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* --- HEADER & NAV --- */
header {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-header);
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--color-cyan) 0%, var(--color-violet) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-tabs { display: flex; gap: 8px; }

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-header);
    font-size: 15px;
    font-weight: 500;
    padding: 8px 16px;
    min-height: var(--touch);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-btn:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.05); }

.tab-btn.active {
    color: #fff;
    background: var(--color-violet);
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.4);
}

.tab-icon { font-size: 16px; }

/* --- LAYOUT --- */
main {
    max-width: 1200px;
    margin: 28px auto;
    padding: 0 24px 40px;
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.35s ease-out; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.section-title { margin-bottom: 24px; }

/* --- BANNER --- */
.warning-banner {
    background: linear-gradient(90deg, rgba(244, 63, 94, 0.15) 0%, rgba(124, 58, 237, 0.05) 100%);
    border: 1px solid rgba(244, 63, 94, 0.3);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #fda4af;
}

/* --- STATS --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    transition: var(--transition-smooth);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(6, 182, 212, 0.3);
    background: var(--bg-card-hover);
}

.stat-card h4 {
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.stat-number {
    font-family: var(--font-header);
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* --- RECOMMENDATION CARD --- */
.rec-card {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.15) 0%, rgba(6, 182, 212, 0.05) 100%);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.rec-eyebrow {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--color-cyan);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.rec-info h3 {
    font-size: 24px;
    margin: 6px 0 8px;
    color: #fff;
    text-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

.rec-info p { color: var(--text-secondary); line-height: 1.6; font-size: 15px; }
.rec-info p strong { color: #fff; }
.nudge { color: var(--color-emerald); display: inline-block; margin-top: 6px; }
.rec-start { padding: 14px 26px; font-size: 15px; white-space: nowrap; }

/* --- DASHBOARD GRID & CHARTS --- */
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }

.chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
}

.chart-section h3 {
    margin-bottom: 20px;
    font-size: 18px;
    border-left: 4px solid var(--color-cyan);
    padding-left: 10px;
}

.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-caption {
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-align: center;
}
.chart-container { position: relative; height: 240px; width: 100%; }
.chart-short { height: 200px; }
.chart-block { margin-top: 28px; }

.recent-history-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
}

.recent-history-container h3 { margin-bottom: 16px; font-size: 18px; }

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.history-item:last-child { border-bottom: none; }
.h-name { font-weight: 600; font-size: 14px; }
.h-date { font-size: 12px; color: var(--text-muted); }
.h-calories { color: var(--color-cyan); font-weight: 700; font-size: 14px; }
.empty-note { color: var(--text-muted); font-size: 14px; line-height: 1.6; }

/* --- WORKOUT CARDS --- */
.workouts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
}

.workout-card {
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 20px;
    transition: var(--transition-smooth);
}

.workout-card:hover {
    border-color: rgba(124, 58, 237, 0.3);
    background: var(--bg-card-hover);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.workout-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.workout-header h3 { font-size: 19px; color: #fff; margin-bottom: 6px; }

.badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-high-impact { background: rgba(244, 63, 94, 0.15); color: var(--color-rose); border: 1px solid rgba(244, 63, 94, 0.3); }
.badge-low-impact { background: rgba(16, 185, 129, 0.15); color: var(--color-emerald); border: 1px solid rgba(16, 185, 129, 0.3); }

.knee-warning-item {
    font-size: 12px;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 14px;
    line-height: 1.5;
}

.exercise-list { display: flex; flex-direction: column; gap: 8px; }

.exercise-row-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px;
    min-height: var(--touch);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.exercise-row-display:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(6, 182, 212, 0.2);
}

.ex-info-click { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ex-origin { font-size: 11px; color: var(--text-muted); }
.ex-values { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

.ex-badge {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 500;
    white-space: nowrap;
}

.tag-high {
    font-size: 9px;
    font-weight: 700;
    color: var(--color-rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
    padding: 2px 5px;
    border-radius: 4px;
}

/* --- BUTTONS & FORMS --- */
.primary-btn {
    background: linear-gradient(135deg, var(--color-violet) 0%, #6d28d9 100%);
    border: none;
    color: #fff;
    font-family: var(--font-header);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 18px;
    min-height: var(--touch);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.primary-btn:hover { opacity: 0.95; transform: translateY(-1px); }

.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-header);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 16px;
    min-height: var(--touch);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.secondary-btn:hover { background: rgba(255, 255, 255, 0.1); }
.btn-block { width: 100%; }

.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #fff;
    padding: 12px 14px;
    min-height: var(--touch);
    font-family: var(--font-body);
    font-size: 15px;
    transition: var(--transition-smooth);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-cyan);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

.form-group select option { background: #0f172a; color: #fff; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.checkbox-group { display: flex; align-items: center; gap: 10px; }
.checkbox-group input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--color-rose); }
.checkbox-group label { margin: 0; cursor: pointer; color: #fda4af; }

.logger-card {
    max-width: 560px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 28px;
}

/* --- MODALS --- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
}

.modal.open { opacity: 1; pointer-events: auto; }

.modal-content {
    background: #111827;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    width: 92%;
    max-width: 680px;
    max-height: 88vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.96);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
}

.modal.open .modal-content { transform: scale(1); }
.modal-content.narrow { max-width: 480px; display: block; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 14px;
}

.modal-header h2 { font-size: 20px; }
.session-clock { font-size: 13px; color: var(--color-cyan); font-weight: 600; margin-top: 4px; }

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    min-width: var(--touch);
    min-height: var(--touch);
    cursor: pointer;
}

.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 16px; }

/* --- RUNNER --- */
.active-workout-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
    overflow-y: auto;
    flex: 1;
}

.active-ex-row {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.active-ex-row:has(.ex-checkbox:checked) {
    border-color: rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.05);
}

.active-ex-meta { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 200px; }
.active-ex-text { min-width: 0; }

.ex-checkbox {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    accent-color: var(--color-emerald);
    cursor: pointer;
}

.active-ex-name { font-weight: 600; font-size: 15px; cursor: pointer; }
.ex-target-line { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ex-sub-line { font-size: 12px; color: #fda4af; margin-top: 4px; }

.active-ex-inputs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.input-unit-group {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 6px 10px;
    width: 96px;
    min-height: var(--touch);
}

.input-unit-group input {
    width: 100%;
    background: transparent;
    border: none;
    color: #fff;
    text-align: center;
    font-weight: 700;
    font-size: 15px;
}

.input-unit-group input:focus { outline: none; }
.input-unit-group span { font-size: 11px; color: var(--text-muted); }

.timer-trigger-btn {
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: var(--color-cyan);
    font-size: 12px;
    font-weight: 600;
    padding: 8px 12px;
    min-height: var(--touch);
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.timer-trigger-btn:disabled { opacity: 0.9; font-variant-numeric: tabular-nums; }

.runner-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rest-row { display: flex; align-items: center; gap: 8px; }
.rest-label { font-size: 12px; color: var(--text-muted); }

.rest-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    min-height: var(--touch);
    border-radius: 8px;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}

.rest-btn.running {
    background: rgba(6, 182, 212, 0.15);
    border-color: rgba(6, 182, 212, 0.4);
    color: var(--color-cyan);
}

.complete-row { display: flex; gap: 10px; align-items: center; }
.duration-group { width: 110px; }
.complete-btn {
    flex: 1;
    background: linear-gradient(135deg, var(--color-emerald) 0%, #047857 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* --- DRAWER --- */
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 460px;
    background: #111827;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
    z-index: 1050;
    transform: translateX(100%);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.drawer-section-title {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.drawer-strong { font-weight: 600; }
.drawer-text { line-height: 1.6; font-size: 14px; }
.drawer-link { display: inline-block; text-align: center; text-decoration: none; margin-top: 8px; }

/* --- SYNC & SETTINGS --- */
.sync-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.sync-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
}

.card-title { margin-bottom: 18px; }
.card-title.divided {
    margin-top: 28px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 22px;
}
.card-note { color: var(--text-secondary); font-size: 13px; line-height: 1.6; margin-bottom: 14px; }
.card-note.muted { color: var(--text-muted); font-size: 12px; margin: 14px 0 0; }
.accent-cyan { color: var(--color-cyan); }
.accent-violet { color: #a78bfa; }

.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    background: rgba(255, 255, 255, 0.01);
}

.drop-zone.drag-over { border-color: var(--color-cyan); background: rgba(6, 182, 212, 0.05); }
.drop-zone-icon { font-size: 32px; margin-bottom: 10px; }
.drop-zone-title { font-weight: 600; }
.drop-zone-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.simulator-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.utility-stack { display: flex; flex-direction: column; gap: 16px; }
.utility-stack h4 { font-size: 14px; margin-bottom: 6px; }
.divided-top { border-top: 1px solid rgba(255, 255, 255, 0.05); padding-top: 16px; }

.schedule-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.schedule-row {
    display: grid;
    grid-template-columns: 92px 1fr 130px;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 10px;
}

.schedule-day { font-weight: 600; color: var(--text-secondary); font-size: 13px; }

.schedule-type-select,
.schedule-time-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #fff;
    padding: 10px;
    min-height: var(--touch);
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    width: 100%;
}

.schedule-type-select option { background: #0f172a; color: #fff; }
.schedule-time-input:disabled { opacity: 0.3; cursor: not-allowed; }

/* --- FEATURE ROUND 2: tags, editor, picker, photos, muscles --- */
.head-actions { display: flex; gap: 8px; }
.card-actions { display: flex; gap: 8px; align-items: flex-start; flex-shrink: 0; }

.view-toggle { display: flex; gap: 8px; margin-bottom: 18px; }
#libraryList { max-width: 720px; }

.routine-pick-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 55vh;
    overflow-y: auto;
}
.routine-pick {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    padding: 12px 14px;
    min-height: var(--touch);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.routine-pick:hover:not(:disabled) { border-color: rgba(124, 58, 237, 0.4); background: rgba(124, 58, 237, 0.08); }
.routine-pick span { font-size: 12px; color: var(--text-muted); }
.routine-pick.has { opacity: 0.45; cursor: default; }

/* Accordion + group filter */
.group-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.group-chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: var(--font-header);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    min-height: var(--touch);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.group-chip:hover { color: var(--text-primary); }
.group-chip.active {
    background: rgba(124, 58, 237, 0.2);
    border-color: rgba(124, 58, 237, 0.5);
    color: #fff;
}
.workout-header { cursor: pointer; }
.chev { color: var(--text-muted); font-size: 14px; margin-right: 2px; }
.workout-card .exercise-list, .workout-card .knee-warning-item { display: none; }
.workout-card.open .exercise-list { display: flex; }
.workout-card.open .knee-warning-item { display: block; }
.btn-icon { padding: 10px 12px; font-size: 15px; }
.secondary-btn.danger { color: var(--color-rose); border-color: rgba(244, 63, 94, 0.3); margin-right: auto; }

.ex-badge-edit { cursor: pointer; border: 1px dashed rgba(6, 182, 212, 0.35); }
.ex-badge-edit:hover { background: rgba(6, 182, 212, 0.12); color: var(--color-cyan); }

.tag-back { color: #fbbf24; border-color: rgba(251, 191, 36, 0.35); }
.tag-shoulder { color: #a78bfa; border-color: rgba(167, 139, 250, 0.35); }

.safety-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.safety-badge {
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 8px;
    font-weight: 600;
}
.safety-ok { background: rgba(16, 185, 129, 0.12); color: var(--color-emerald); border: 1px solid rgba(16, 185, 129, 0.3); }
.safety-caution { background: rgba(251, 191, 36, 0.1); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.3); }

.photo-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin-bottom: 10px;
    -webkit-overflow-scrolling: touch;
}
.photo-item { position: relative; flex-shrink: 0; }
.photo-item img {
    height: 180px;
    max-width: 300px;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.25);
}
.photo-del {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(11, 15, 25, 0.8);
    color: var(--color-rose);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.photo-actions { display: flex; gap: 8px; margin-bottom: 6px; }

.picker-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}
.picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}
.picker-item:hover { background: rgba(255, 255, 255, 0.05); }
.picker-item.picked { background: rgba(124, 58, 237, 0.12); }
.picker-item input { width: 18px; height: 18px; accent-color: var(--color-violet); flex-shrink: 0; }
.picker-name { flex: 1; font-weight: 500; }
.picker-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 6px; align-items: center; }
.picker-order {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-cyan);
    background: rgba(6, 182, 212, 0.12);
    padding: 2px 7px;
    border-radius: 10px;
}
.picker-selected {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    max-height: 90px;
    overflow-y: auto;
}

.flag-row { display: flex; flex-direction: column; gap: 10px; }
.flag-check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-secondary); cursor: pointer; }
.flag-check input { width: 18px; height: 18px; accent-color: var(--color-rose); }

.muscle-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.muscle-chip {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-cyan);
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.25);
    padding: 2px 8px;
    border-radius: 10px;
}

.recency-row {
    display: flex;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}
.rec-fresh { background: rgba(16, 185, 129, 0.08); color: var(--color-emerald); }
.rec-aging { background: rgba(251, 191, 36, 0.08); color: #fbbf24; }
.rec-stale { background: rgba(244, 63, 94, 0.08); color: var(--color-rose); }

/* --- ADMIN PANEL --- */
.admin-user {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
}
.admin-user-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.admin-device {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 0 0;
}
.admin-device.muted { color: var(--text-muted); font-size: 12px; }
.admin-revoke {
    background: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: var(--color-rose);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
}
.invite-qr { display: flex; justify-content: center; margin: 10px 0; }
.invite-qr svg { background: #fff; border-radius: 8px; }
#inviteLink {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    padding: 10px;
    font-size: 12px;
}

/* --- TOAST --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translate(-50%, 20px);
    background: #1f2937;
    border: 1px solid rgba(6, 182, 212, 0.4);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
    z-index: 2000;
    max-width: 90vw;
    text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- MOBILE: bottom nav + fullscreen runner --- */
@media (max-width: 820px) {
    body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

    /* backdrop-filter creates a containing block that would trap the
       fixed-position bottom nav inside the header — disable it here. */
    header { backdrop-filter: none; background: rgba(15, 23, 42, 0.9); }

    .header-container { justify-content: center; padding: 12px 16px; }

    /* Bottom tab bar */
    .nav-tabs {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 900;
        background: rgba(15, 23, 42, 0.92);
        backdrop-filter: blur(16px);
        border-top: 1px solid var(--border-color);
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        justify-content: space-around;
        gap: 0;
    }

    .tab-btn {
        flex-direction: column;
        gap: 2px;
        font-size: 11px;
        padding: 6px 10px;
        flex: 1;
        max-width: 90px;
    }

    .tab-icon { font-size: 20px; }

    .tab-btn.active { background: rgba(124, 58, 237, 0.25); box-shadow: none; }

    main { margin: 20px auto; padding: 0 14px 20px; }

    .dashboard-grid, .charts-row, .sync-grid { grid-template-columns: 1fr; }
    .workouts-grid { grid-template-columns: 1fr; }

    .rec-card { flex-direction: column; align-items: stretch; padding: 20px; }
    .rec-start { width: 100%; }

    .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .stat-card { padding: 14px 8px; }
    .stat-number { font-size: 18px; }

    /* Fullscreen workout runner */
    .modal-content.runner {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    }

    .active-ex-row { padding: 12px; }
    .active-ex-inputs { width: 100%; justify-content: flex-end; }

    .toast { bottom: calc(90px + env(safe-area-inset-bottom)); }

    .schedule-row { grid-template-columns: 78px 1fr 112px; }
    .form-row { grid-template-columns: 1fr; }
    .chart-container { height: 220px; }
}
