:root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-hover: #21262d;
    --border: rgba(255, 255, 255, 0.1);
    --border-accent: rgba(255, 107, 107, 0.3);
    
    --primary: #ff6b6b;
    --primary-variant: #e05b5b;
    --primary-glow: rgba(255, 107, 107, 0.35);

    --warmup: #38d9a9;
    --warmup-glow: rgba(56, 217, 169, 0.25);

    --mob: #4dabf7;
    --mob-glow: rgba(77, 171, 247, 0.25);

    --renfo: #ff922b;
    --renfo-glow: rgba(255, 146, 43, 0.25);

    --text: #f0f6fc;
    --text-sec: #8b949e;
    --text-muted: #6e7681;

    --card-radius: 20px;
    --btn-radius: 14px;
    --shadow-main: 0 10px 30px rgba(0, 0, 0, 0.4);
}

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    text-align: center;
    overflow-x: hidden;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.hidden {
    display: none !important;
}

.container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 20px 16px;
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
    position: relative;
}

/* =========================================
   TYPOGRAPHIE
   ========================================= */
h1 {
    font-size: 2.2rem;
    margin: 5px 0 8px 0;
    color: var(--primary);
    font-weight: 800;
    letter-spacing: -0.5px;
}

h2 {
    font-size: 1.6rem;
    margin: 0 0 10px 0;
    font-weight: 700;
}

h3 {
    margin: 0;
    font-size: 1.2rem;
}

p {
    font-size: 1rem;
    color: var(--text-sec);
    line-height: 1.5;
    margin: 0 0 20px 0;
}

.subtitle {
    font-size: 1.05rem;
    color: var(--text-sec);
    margin-bottom: 22px;
}

/* =========================================
   BOUTONS
   ========================================= */
button, .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: white;
    border: none;
    border-radius: var(--btn-radius);
    padding: 16px 20px;
    font-size: 1.15rem;
    font-weight: 700;
    width: 100%;
    margin: 0 auto 12px auto;
    cursor: pointer;
    transition: transform 0.1s ease, filter 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
}

button:active, .btn:active {
    transform: scale(0.97);
}

button:disabled, .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-mixte {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5253 100%);
    box-shadow: 0 4px 18px var(--primary-glow);
}

.btn-mob {
    background: linear-gradient(135deg, #4dabf7 0%, #339af0 100%);
    box-shadow: 0 4px 18px var(--mob-glow);
}

.btn-renfo {
    background: linear-gradient(135deg, #ff922b 0%, #f76707 100%);
    box-shadow: 0 4px 18px var(--renfo-glow);
}

.btn-warm {
    background: linear-gradient(135deg, #38d9a9 0%, #20c997 100%);
    color: #0d1117;
    box-shadow: 0 4px 18px var(--warmup-glow);
}

.btn-secondary {
    background-color: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: none;
    font-size: 1rem;
    padding: 14px 18px;
}

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

.btn-danger {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ff6b6b;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-small {
    padding: 10px 14px;
    font-size: 0.95rem;
    border-radius: 10px;
    width: auto;
    display: inline-flex;
}

/* =========================================
   BADGES & TAGS
   ========================================= */
.tag {
    display: inline-flex;
    align-items: center;
    background: #2a2e37;
    color: #fff;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
    margin-bottom: 12px;
}

.tag.mob { background: rgba(77, 171, 247, 0.2); color: #74c0fc; border: 1px solid rgba(77, 171, 247, 0.4); }
.tag.renfo { background: rgba(255, 146, 43, 0.2); color: #ffa94d; border: 1px solid rgba(255, 146, 43, 0.4); }
.tag.warm { background: rgba(56, 217, 169, 0.2); color: #63e6be; border: 1px solid rgba(56, 217, 169, 0.4); }

.tag-equipment {
    display: inline-block;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-sec);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin: 4px 2px;
    border: 1px solid var(--border);
}

/* =========================================
   CARTES
   ========================================= */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 24px 18px;
    border-radius: var(--card-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-main);
    text-align: left;
    position: relative;
    backdrop-filter: blur(8px);
}

.card-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.kine-tip-box {
    background: rgba(255, 146, 43, 0.1);
    border-left: 4px solid var(--renfo);
    padding: 10px 14px;
    border-radius: 0 10px 10px 0;
    margin-top: 14px;
    font-size: 0.92rem;
    line-height: 1.4;
    color: #ffc078;
}

.target-badge {
    color: var(--mob);
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 8px;
}

/* =========================================
   BARRE DE PROGRESSION & HEADER WORKOUT
   ========================================= */
.workout-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-info {
    text-align: left;
}

.round-info {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
}

.exo-info {
    font-size: 0.95rem;
    color: var(--text-sec);
    font-weight: 600;
}

.quick-audio-bar {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    padding: 0;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn.off {
    opacity: 0.4;
    background: #111;
}

.progress-track {
    width: 100%;
    height: 6px;
    background: #21262d;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--mob) 0%, var(--primary) 100%);
    width: 0%;
    transition: width 0.3s ease;
}

/* =========================================
   CHRONOMÈTRE SVG CIRCULAIRE
   ========================================= */
.timer-container {
    position: relative;
    width: 170px;
    height: 170px;
    margin: 15px auto;
}

.timer-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.timer-circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 8;
}

.timer-circle-progress {
    fill: none;
    stroke: var(--primary);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.25s linear, stroke 0.3s ease;
}

.timer-circle-progress.rest {
    stroke: var(--mob);
}

.timer-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.timer-countdown {
    font-size: 3.4rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    line-height: 1;
}

.timer-unit {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-sec);
    margin-top: 4px;
    font-weight: 600;
}

.timer-controls-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 14px;
}

.btn-time-adjust {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    width: auto;
    margin: 0;
}

.paused-state {
    background: linear-gradient(135deg, #ffd43b 0%, #fab005 100%) !important;
    color: #121212 !important;
}

/* Bannière Switch Side */
.switch-side-banner {
    background: linear-gradient(90deg, #ff922b, #ff6b6b);
    color: white;
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 1.05rem;
    margin-bottom: 15px;
    animation: pulse 1s infinite alternate;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

@keyframes pulse {
    0% { transform: scale(0.98); opacity: 0.9; }
    100% { transform: scale(1.02); opacity: 1; }
}

/* =========================================
   CONTENEUR RÉPÉTITIONS
   ========================================= */
.reps-container {
    text-align: center;
    padding: 10px 0;
}

.rep-target-badge {
    display: inline-block;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    background: rgba(255, 107, 107, 0.12);
    border: 2px solid rgba(255, 107, 107, 0.4);
    padding: 12px 24px;
    border-radius: 16px;
    margin-bottom: 12px;
}

.reps-tip {
    font-size: 0.95rem;
    color: var(--text-sec);
}

/* =========================================
   LISTES APERÇU & BIBLIOTHÈQUE
   ========================================= */
.list-wrapper {
    flex: 1;
    overflow-y: auto;
    text-align: left;
    margin-bottom: 18px;
    padding-right: 4px;
}

.list-category {
    font-size: 1.15rem;
    margin-top: 18px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

.list-category.warm { color: var(--warmup); }
.list-category.mob { color: var(--mob); }
.list-category.renfo { color: var(--renfo); }

.preview-list {
    list-style-type: none;
    padding-left: 0;
    margin: 0 0 16px 0;
}

.preview-list li {
    background: var(--surface);
    padding: 12px 14px;
    margin-bottom: 8px;
    border-radius: 12px;
    border-left: 4px solid var(--primary);
    border-top: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.preview-list.warm li { border-left-color: var(--warmup); }
.preview-list.mob-mode li { border-left-color: var(--mob); }
.preview-list.renfo-mode li { border-left-color: var(--renfo); }

.exo-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.exo-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
}

.exo-badge {
    font-size: 0.85rem;
    color: var(--text-sec);
    background: rgba(255, 255, 255, 0.08);
    padding: 3px 8px;
    border-radius: 6px;
}

/* Cartes Bibliothèque */
.library-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    text-align: left;
}

.library-card-header {
    margin-bottom: 8px;
}

.library-title {
    font-size: 1.15rem;
    color: var(--text);
    margin-top: 6px;
}

.library-desc {
    font-size: 0.95rem;
    color: var(--text-sec);
    margin: 6px 0 10px 0;
}

.library-tip {
    font-size: 0.88rem;
    background: rgba(255, 146, 43, 0.08);
    border-left: 3px solid var(--renfo);
    color: #ffc078;
    padding: 6px 10px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 8px;
}

.library-target {
    font-size: 0.85rem;
    color: var(--mob);
}

.library-equip {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-left: 6px;
}

/* Filtres de la bibliothèque */
.filter-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 10px;
    -webkit-overflow-scrolling: touch;
}

.filter-pill {
    white-space: nowrap;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.88rem;
    font-weight: 600;
    background: var(--surface);
    color: var(--text-sec);
    border: 1px solid var(--border);
    cursor: pointer;
    width: auto;
    margin: 0;
}

.filter-pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.search-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 1rem;
    margin-bottom: 12px;
    outline: none;
}

.search-input:focus {
    border-color: var(--primary);
}

/* =========================================
   ÉCHELLE DE DOULEUR (EVA 0-10)
   ========================================= */
.pain-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
    text-align: left;
}

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

.pain-value-badge {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
    background: rgba(255, 107, 107, 0.15);
    padding: 4px 12px;
    border-radius: 10px;
}

.pain-slider {
    width: 100%;
    margin: 8px 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.pain-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* =========================================
   STATS & HISTORIQUE
   ========================================= */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    text-align: center;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-sec);
    margin-top: 4px;
}

.history-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 10px;
    text-align: left;
}

.history-top {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    margin-bottom: 6px;
}

.history-date {
    color: var(--text-sec);
    font-size: 0.85rem;
}

.history-type {
    color: var(--primary);
    font-size: 0.95rem;
}

.history-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-sec);
}

.pain-badge {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
}

.pain-badge.relief { background: rgba(56, 217, 169, 0.2); color: #38d9a9; }
.pain-badge.neutral { background: rgba(255, 255, 255, 0.08); color: var(--text-sec); }
.pain-badge.warning { background: rgba(255, 146, 43, 0.2); color: #ff922b; }

.empty-state {
    padding: 30px 10px;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* =========================================
   FORMULAIRES & RÉGLAGES
   ========================================= */
.settings-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    text-align: left;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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

.setting-row label {
    font-weight: 600;
    font-size: 0.98rem;
}

.setting-row select, .setting-row input[type="number"] {
    background: #0d1117;
    border: 1px solid var(--border);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-switch {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #333;
    transition: .3s;
    border-radius: 26px;
}

.slider-switch:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider-switch {
    background-color: var(--primary);
}

input:checked + .slider-switch:before {
    transform: translateX(22px);
}

/* =========================================
   CONFETTIS (ÉCRAN VICTOIRE)
   ========================================= */
.confetti-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 100;
}

.confetti-piece {
    position: absolute;
    width: 8px;
    height: 14px;
    top: -20px;
    border-radius: 2px;
    animation: fall 3s ease-out forwards;
}

@keyframes fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* =========================================
   BARRE DE COMMANDES WORKOUT INFÉRIEURE
   ========================================= */
.workout-footer-bar {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.workout-footer-bar button {
    margin-bottom: 0;
}
