:root, [data-theme="dark"]{
    --bg:#0f172a;
    --card-bg:#1e293b;
    --surface:#334155;
    --text:#ffffff;
    --text-muted:#94a3b8;
    --accent:#22c55e;
    --danger:#ef4444;
    --info:#3b82f6;
}

[data-theme="light"]{
    --bg:#f1f5f9;
    --card-bg:#ffffff;
    --surface:#e2e8f0;
    --text:#0f172a;
    --text-muted:#64748b;
    --accent:#16a34a;
    --danger:#dc2626;
    --info:#2563eb;
}

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

body{
    background:var(--bg);
    color:var(--text);
    font-family:Arial,Helvetica,sans-serif;
    -webkit-tap-highlight-color:transparent;
    transition:background .2s,color .2s;
}

.page{
    width:min(900px,95%);
    margin:auto;
    padding:35px;
    padding-top:calc(35px + env(safe-area-inset-top));
    padding-bottom:calc(35px + env(safe-area-inset-bottom));
}

.header{
    text-align:center;
    margin-bottom:35px;
}

.header h1{
    font-size:clamp(26px, 8vw, 46px);
    margin-bottom:10px;
}

.header p{
    color:var(--text-muted);
}

.card{
    background:var(--card-bg);
    border-radius:20px;
    padding:25px;
    margin-bottom:25px;
    box-shadow:0 15px 40px rgba(0,0,0,.2);
}

.card-title{
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:20px;
}

.create-row{
    display:flex;
    gap:12px;
}

input{
    flex:1;
    width:100%;
    background:var(--surface);
    color:var(--text);
    border:none;
    outline:none;
    border-radius:14px;
    padding:16px;
    font-size:18px;
}
button{
    border:none;
    border-radius:14px;
    cursor:pointer;
    padding:16px 24px;
    font-size:17px;
    background:var(--accent);
    color:white;
    transition:.2s;
}

button:hover{
    transform:translateY(-2px);
}

button:disabled{
    opacity:.3;
    cursor:default;
}

button:disabled:hover{
    transform:none;
}

.workout{
    display:flex;
    justify-content:space-between;
    align-items:center;
    background:var(--surface);
    border-radius:14px;
    padding:18px;
    margin-top:14px;
}

.workout-name{
    font-size:20px;
    font-weight:bold;
}

.actions{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
}

.open{
    background:var(--info);
}

.delete{
    background:var(--danger);
}

.empty{
    text-align:center;
    color:var(--text-muted);
    padding:30px;
}

.theme-toggle{
    position:fixed;
    top:calc(16px + env(safe-area-inset-top));
    right:16px;
    width:48px;
    height:48px;
    border-radius:50%;
    background:var(--card-bg);
    color:var(--text);
    font-size:20px;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:0;
    box-shadow:0 8px 20px rgba(0,0,0,.25);
    z-index:50;
}

/* ===== En-tête de page avec bouton(s) retour ===== */

.page-top{
    display:flex;
    align-items:center;
    gap:10px;
    margin-bottom:20px;
    padding-right:60px;
}

.page-top h1{
    flex:1;
    text-align:center;
    font-size:24px;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.icon-btn{
    background:var(--surface);
    color:var(--text);
    width:48px;
    height:48px;
    min-width:48px;
    border-radius:14px;
    font-size:22px;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:0;
}

/* ===== Renommer / dupliquer / modifier / réordonner ===== */

.workout-meta-actions{
    display:flex;
    gap:10px;
    margin-bottom:20px;
}

.secondary-btn{
    flex:1;
    background:var(--surface);
    color:var(--text);
    font-size:15px;
    padding:12px;
}

.exercise-actions{
    flex-wrap:wrap;
    justify-content:flex-end;
}

.move-btn,
.edit-btn{
    background:var(--surface);
    color:var(--text);
    padding:10px 14px;
    font-size:16px;
}

.exercise-edit-row{
    flex-direction:column;
    align-items:stretch;
}

.edit-fields{
    display:flex;
    flex-direction:column;
    gap:10px;
    margin-bottom:14px;
}

/* ===== Comptes utilisateurs ===== */

.user-bar{
    margin-top:14px;
    font-size:14px;
    color:var(--text-muted);
}

.user-bar a{
    color:var(--accent);
}

.auth-page{
    max-width:420px;
}

.error-msg{
    background:rgba(239,68,68,.15);
    color:var(--danger);
    padding:14px;
    border-radius:12px;
    margin-bottom:18px;
}

.auth-switch{
    text-align:center;
    margin-top:18px;
    color:var(--text-muted);
}

.auth-switch a{
    color:var(--accent);
    display:block;
    margin-top:8px;
}

/* ===== Timer ===== */

.timer-page{
    padding-top:calc(20px + env(safe-area-inset-top));
}

.hidden{
    display:none;
}

.start-gate{
    text-align:center;
}

.start-btn{
    margin-top:15px;
    padding:18px 32px;
    font-size:19px;
}

.timer-card{
    text-align:center;
}

.phase-label{
    color:var(--text-muted);
    text-transform:uppercase;
    letter-spacing:2px;
    font-size:14px;
    margin-bottom:10px;
}

.timer-card h2{
    font-size:24px;
    margin-bottom:10px;
}

.countdown-wrap{
    margin:20px 0;
}

#countdown{
    font-size:96px;
    font-weight:bold;
    line-height:1;
}

.progress-bar{
    height:10px;
    background:var(--surface);
    border-radius:6px;
    overflow:hidden;
    margin-top:20px;
}

.progress-fill{
    height:100%;
    background:var(--accent);
    width:0%;
    transition:width 1s linear;
}

.exercise-position{
    color:var(--text-muted);
    margin-top:14px;
    font-size:14px;
}

.timer-controls{
    display:flex;
    justify-content:center;
    gap:16px;
    margin:25px 0;
}

.control-btn{
    width:64px;
    height:64px;
    border-radius:50%;
    background:var(--surface);
    color:var(--text);
    font-size:26px;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:0;
    user-select:none;
}

.control-btn.primary{
    width:78px;
    height:78px;
    background:var(--accent);
    color:white;
    font-size:32px;
}

.quit-btn{
    width:100%;
    background:var(--danger);
}

@media(max-width:700px){

.create-row{
flex-direction:column;
}

.workout{
flex-direction:column;
align-items:flex-start;
gap:15px;
}

.actions{
width:100%;
}

.actions button{
flex:1;
}

}

.field-hint{
    color:var(--text-muted);
    font-size:13px;
    margin:10px 0 16px;
}

button[type="submit"]{
    width:100%;
}
