:root {
    --bg-color: #121212; /* Fond sombre profond */
    --card-bg: #1e1e1e; /* Fond des cartes légèrement plus clair */
    --primary: #4A90E2; /* Bleu d'accentuation */
    --primary-dim: #3a76bb;
    --danger: #E24A4A;
    --text: #e0e0e0; /* Texte clair */
    --text-dim: #a0a0a0;
    --border-color: #333333;
    --radius: 16px;
    --shadow: 0 8px 16px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Lexend', sans-serif; }

body { background-color: var(--bg-color); color: var(--text); padding-bottom: 20px; transition: background 0.3s; }

.view { display: none; padding: 20px; max-width: 600px; margin: 0 auto; }
.view.active { display: block; }

/* === ANIMATIONS === */
@keyframes fadeInPop {
    from { opacity: 0; transform: translateY(15px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.fade-in { animation: fadeInPop 0.4s ease-out forwards; }
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }

header { display: flex; align-items: center; margin-bottom: 20px; gap: 15px; }
h1 { color: #ffffff; font-weight: 700; font-size: 2.2rem; }
h2 { color: var(--primary); font-weight: 600; font-size: 1.6rem; }
h3 { color: var(--text); font-weight: 600; font-size: 1.2rem; margin-bottom: 15px; }

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

p { color: var(--text-dim); margin-bottom: 15px; }

input {
    width: 100%; padding: 18px; margin-bottom: 12px; border: 1px solid var(--border-color);
    border-radius: var(--radius); font-size: 16px; outline: none; background-color: rgba(255, 255, 255, 0.03);
    color: #ffffff; transition: border-color 0.2s;
}
input:focus { border-color: var(--primary); background-color: rgba(255, 255, 255, 0.06); }

button {
    background: var(--primary); color: white; border: none; padding: 18px;
    border-radius: var(--radius); font-size: 16px; cursor: pointer; width: 100%; font-weight: 600;
    transition: background 0.2s, transform 0.1s;
}
button:hover { background: var(--primary-dim); }
button:active { transform: scale(0.97); }

.flex-row { display: flex; gap: 12px; }
.flex-row input { margin-bottom: 0; }
.flex-row button { width: auto; padding: 18px 25px; }

.btn-danger { background: rgba(226, 74, 74, 0.15); color: var(--danger); }
.btn-danger:hover { background: rgba(226, 74, 74, 0.25); }
.btn-danger.confirm { background: var(--danger); color: white; border: 2px solid #ffffff; }

.back-btn { background: transparent; color: var(--primary); width: auto; padding: 0; font-size: 18px; font-weight: 400; }
.back-btn:hover { color: var(--primary-dim); background: transparent; }

.exercise-item {
    padding: 20px; border-radius: var(--radius); background: var(--card-bg);
    display: flex; justify-content: space-between; align-items: center; cursor: pointer;
    margin-bottom: 12px; border: 1px solid var(--border-color); transition: all 0.2s ease;
}
.exercise-item:hover { border-color: var(--primary); background: rgba(74, 144, 226, 0.05); transform: translateY(-2px); }
.exercise-item strong { color: #ffffff; font-weight: 600; font-size: 1.1rem; }
.exercise-item span { color: var(--primary); }

.error { color: var(--danger); font-size: 14px; margin-top: 12px; font-weight: 400; }
.danger-zone { margin-top: 40px; text-align: center; border-color: rgba(226, 74, 74, 0.3); }

/* === NOUVEAU : HISTORIQUE === */
.history-list {
    max-height: 250px; /* Limite la hauteur pour avoir un scroll si c'est trop long */
    overflow-y: auto;
    padding-right: 5px;
}

/* Personnalisation de la scrollbar pour Webkit */
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.history-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.history-date {
    color: var(--text-dim);
    font-size: 0.95rem;
}
.history-weight {
    color: #ffffff;
    font-weight: 600;
    font-size: 1.1rem;
}
.history-weight span {
    color: var(--primary);
    font-size: 0.9rem;
    margin-left: 4px;
}

/* Zone de notifications */
#notification-area {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 1000;
    width: 90%; max-width: 400px; display: flex; flex-direction: column; gap: 10px;
}

.notification {
    background: #ffffff; color: #121212; padding: 18px 25px; border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); font-weight: 600; font-size: 1.1rem; text-align: center;
    border-left: 5px solid var(--primary); animation: notifyPop 0.5s ease-out, notifyOut 0.5s ease-in 3.5s forwards;
    display: flex; align-items: center; gap: 10px; justify-content: center;
}

@keyframes notifyPop {
    0% { opacity: 0; transform: translateY(-50px) scale(0.9); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes notifyOut {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-20px) scale(0.9); }
}

canvas { width: 100% !important; max-height: 280px; }