/* =====================================================================
   Muscle Ranks — style.css
   Design sombre premium, mobile-first, CSS vanilla (zéro framework).
   ===================================================================== */

/* ---------- Variables ---------------------------------------------- */
:root {
    --bg-0: #0b0d12;
    --bg-1: #11141c;
    --bg-2: #171a24;
    --bg-3: #1e2230;
    --border: #262b3a;
    --border-soft: #1d2130;
    --text: #e6e9f2;
    --text-muted: #8a90a3;
    --text-dim: #5f6578;
    --accent: #6ee7ff;
    --accent-2: #a78bfa;
    --danger: #ef4444;
    --success: #22c55e;

    /* Couleurs de ranks */
    --rank-untrained: #6b7280;
    --rank-bronze:    #b06a3b;
    --rank-silver:    #c5cbd6;
    --rank-gold:      #f0b429;
    --rank-platinum:  #7fd1e4;
    --rank-diamond:   #6ea8ff;
    --rank-master:    #d96cff;
    --rank-legend:    #ff4d6d;

    --radius-sm: 8px;
    --radius:    14px;
    --radius-lg: 20px;

    --shadow-card: 0 8px 24px rgba(0,0,0,.4);
    --shadow-glow: 0 0 24px rgba(110,231,255,.18);

    --max-w: 1180px;
}

/* ---------- Reset léger -------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(110,231,255,.06), transparent 60%),
        radial-gradient(900px 500px at 110% 10%, rgba(167,139,250,.06), transparent 60%),
        var(--bg-0);
    color: var(--text);
    min-height: 100dvh;
    line-height: 1.5;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { opacity: .85; }
button { font-family: inherit; cursor: pointer; }

h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }

.muted { color: var(--text-muted); }
.small { font-size: .85rem; }

/* ---------- Layout ------------------------------------------------- */
.main {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 24px 16px 80px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(11,13,18,.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-soft);
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}
.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #0b0d12;
    font-weight: 800;
    display: grid;
    place-items: center;
    font-size: .85rem;
    box-shadow: var(--shadow-glow);
}
.brand-name { font-weight: 700; letter-spacing: .02em; }
.nav { display: flex; gap: 14px; align-items: center; }
.nav a { color: var(--text-muted); font-weight: 500; font-size: .95rem; }
.nav a:hover, .nav a.active { color: var(--text); }
.nav-logout { color: var(--danger) !important; }

.footer {
    border-top: 1px solid var(--border-soft);
    padding: 24px 16px;
    text-align: center;
    color: var(--text-dim);
}

/* ---------- Buttons ----------------------------------------------- */
.btn-primary, .btn-ghost {
    display: inline-block;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: .95rem;
    border: none;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #0b0d12;
    box-shadow: var(--shadow-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 0 32px rgba(167,139,250,.35); }
.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-2); }
.btn-sm { padding: 8px 14px; font-size: .85rem; }
.full { width: 100%; }

/* ---------- Flash ------------------------------------------------- */
.flash {
    max-width: var(--max-w);
    margin: 16px auto 0;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: .95rem;
}
.flash-success { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.35); color: #aff6c5; }
.flash-error   { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.35); color: #ffbdbd; }

/* ---------- Hero (page d'accueil) --------------------------------- */
.hero { padding: 60px 0 40px; }
.hero-inner { max-width: 760px; }
.hero-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--accent);
    font-size: .75rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 18px;
}
.grad {
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero-sub {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 620px;
    margin-bottom: 28px;
}
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 40px; }

.rank-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 40px;
}
.feature-card {
    background: var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 24px;
}
.feature-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--bg-2);
    display: grid; place-items: center;
    font-size: 1.3rem;
    margin-bottom: 12px;
}

/* ---------- Auth ------------------------------------------------- */
.auth-wrap {
    display: grid;
    place-items: center;
    padding: 40px 0;
}
.auth-card {
    width: 100%;
    max-width: 460px;
    background: var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-card);
}
.auth-sub { color: var(--text-muted); margin-bottom: 20px; }
.auth-alt { text-align: center; margin-top: 16px; color: var(--text-muted); }

/* ---------- Forms ------------------------------------------------ */
.form label {
    display: block;
    margin-bottom: 14px;
    font-size: .9rem;
    color: var(--text-muted);
    font-weight: 500;
}
.form input, .form select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 12px 14px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color .12s, box-shadow .12s;
}
.form input:focus, .form select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(110,231,255,.15);
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
}
.form-row > label { margin-bottom: 0; }

/* ---------- Dashboard ------------------------------------------- */
.dash-head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    margin-bottom: 24px;
    padding: 22px;
    background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
}
@media (min-width: 720px) {
    .dash-head {
        grid-template-columns: auto 1fr;
        align-items: center;
    }
}
.dash-hello small { color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; }
.dash-hello h2 { font-size: 1.8rem; margin-top: 2px; }

.global-rank { text-align: right; }
.global-score {
    display: flex;
    align-items: baseline;
    gap: 6px;
    justify-content: flex-end;
}
.score-value { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; }
.score-max { color: var(--text-dim); font-size: 1rem; }
.global-badge {
    display: inline-block;
    margin-top: 4px;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 700;
    font-size: .85rem;
    letter-spacing: .04em;
}
.xp-bar {
    margin-top: 10px;
    height: 8px;
    background: var(--bg-3);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--border-soft);
}
.xp-fill { height: 100%; border-radius: 999px; transition: width .5s ease; }

.dash-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    margin-bottom: 28px;
}
@media (min-width: 900px) {
    .dash-grid { grid-template-columns: 1fr 380px; }
}

/* Body panel */
.body-panel {
    background: var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 18px;
}
.body-tabs {
    display: flex;
    gap: 6px;
    padding: 4px;
    background: var(--bg-2);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    width: max-content;
    margin: 0 auto 12px;
}
.tab-btn {
    padding: 8px 18px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 999px;
    font-weight: 600;
    font-size: .85rem;
    transition: background .12s, color .12s;
}
.tab-btn.active {
    background: var(--bg-3);
    color: var(--text);
}
.body-stage {
    position: relative;
    aspect-ratio: 200 / 440;
    max-width: 320px;
    margin: 0 auto;
}
.body-view {
    position: absolute;
    inset: 0;
    display: none;
}
.body-view.active { display: block; }
.body-view img, .body-view .body-svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.muscle-dot {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255,255,255,.7);
    box-shadow: 0 0 12px currentColor, 0 2px 8px rgba(0,0,0,.4);
    cursor: pointer;
    transition: transform .12s;
}
.muscle-dot:hover { transform: translate(-50%, -50%) scale(1.25); }

/* Perf panel */
.perf-panel {
    background: var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 22px;
}

/* Section titles */
.section-title {
    font-size: 1.2rem;
    margin: 8px 4px 14px;
    letter-spacing: -.01em;
}

/* Muscle cards */
.muscle-cards { margin-top: 12px; }
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}
.muscle-card {
    background: var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 16px;
    transition: transform .12s, border-color .12s;
}
.muscle-card:hover {
    transform: translateY(-2px);
    border-color: var(--border);
}
.muscle-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.muscle-card-head h4 { margin: 0; }
.muscle-card-ex { color: var(--text-muted); font-size: .85rem; margin: 0 0 10px; }
.muscle-progress {
    height: 6px;
    background: var(--bg-3);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 8px;
}
.muscle-progress-fill {
    height: 100%;
    border-radius: 999px;
    transition: width .5s ease;
}
.muscle-card-foot {
    display: flex;
    justify-content: space-between;
    font-size: .8rem;
    color: var(--text-muted);
}

/* Leaderboard */
.leaderboard { margin-top: 36px; }
.lb-list {
    background: var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.lb-row {
    display: grid;
    grid-template-columns: 40px 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-soft);
}
.lb-row:last-child { border-bottom: none; }
.lb-pos {
    font-weight: 800;
    color: var(--text-dim);
    text-align: center;
}
.lb-pos-1 { color: var(--rank-gold); }
.lb-pos-2 { color: var(--rank-silver); }
.lb-pos-3 { color: var(--rank-bronze); }
.lb-name { font-weight: 600; }
.lb-score { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: .9rem; }

/* ---------- Profile --------------------------------------------- */
.profile-wrap {
    display: grid;
    gap: 18px;
    grid-template-columns: 1fr;
}
@media (min-width: 900px) {
    .profile-wrap { grid-template-columns: 380px 1fr; align-items: start; }
}
.profile-card, .history-card {
    background: var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 22px;
}
.profile-info {
    display: grid;
    gap: 10px;
    margin: 0 0 18px;
}
.profile-info > div {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-soft);
}
.profile-info dt { color: var(--text-muted); font-size: .85rem; margin: 0; }
.profile-info dd { margin: 0; font-weight: 600; }

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}
.history-table th, .history-table td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-soft);
}
.history-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.history-table tr:hover td { background: var(--bg-2); }

/* ---------- Ranks : chips + bg couleurs ------------------------- */
.rank-chip {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #0b0d12;
    background: var(--rank-untrained);
    border: 1px solid rgba(255,255,255,.08);
}
.rank-untrained { background: var(--rank-untrained); color: #fff; }
.rank-bronze    { background: var(--rank-bronze);    color: #fff; }
.rank-silver    { background: var(--rank-silver);    color: #0b0d12; }
.rank-gold      { background: var(--rank-gold);      color: #0b0d12; }
.rank-platinum  { background: var(--rank-platinum);  color: #0b0d12; }
.rank-diamond   { background: var(--rank-diamond);   color: #0b0d12; }
.rank-master    { background: var(--rank-master);    color: #fff; }
.rank-legend    { background: linear-gradient(120deg, #ff4d6d, #ff8c42); color: #fff; }

/* bg (pour barres et dots) */
.rank-untrained-bg { background: var(--rank-untrained); color: var(--rank-untrained); }
.rank-bronze-bg    { background: var(--rank-bronze);    color: var(--rank-bronze); }
.rank-silver-bg    { background: var(--rank-silver);    color: var(--rank-silver); }
.rank-gold-bg      { background: var(--rank-gold);      color: var(--rank-gold); }
.rank-platinum-bg  { background: var(--rank-platinum);  color: var(--rank-platinum); }
.rank-diamond-bg   { background: var(--rank-diamond);   color: var(--rank-diamond); }
.rank-master-bg    { background: var(--rank-master);    color: var(--rank-master); }
.rank-legend-bg    { background: linear-gradient(90deg, #ff4d6d, #ff8c42); color: #ff4d6d; }

/* ---------- Gym themes ----------------------------------------- */
[data-theme="basic_fit"]    { --accent: #ff6b35; --accent-2: #ff3d57; --shadow-glow: 0 0 24px rgba(255,107,53,.25); }
[data-theme="fitness_park"] { --accent: #00e676; --accent-2: #00bcd4; --shadow-glow: 0 0 24px rgba(0,230,118,.22); }
[data-theme="orange_bleu"]  { --accent: #ff9800; --accent-2: #2196f3; --shadow-glow: 0 0 24px rgba(255,152,0,.25); }
[data-theme="neon"]         { --accent: #39ff14; --accent-2: #ff00ff; --shadow-glow: 0 0 24px rgba(57,255,20,.3); }

/* ---------- Body panel wide ------------------------------------ */
.body-panel--wide {
    background: var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 28px;
    text-align: center;
}
.body-hint {
    margin-bottom: 10px;
    font-size: .8rem;
}
.body-panel--wide .body-stage {
    max-width: 280px;
    margin: 0 auto;
}
@media (min-width: 600px) {
    .body-panel--wide .body-stage { max-width: 340px; }
}

/* ---------- Clickable muscle hover ----------------------------- */
.clickable-muscle { transition: filter .12s, opacity .12s; }
.clickable-muscle:hover { filter: brightness(1.25); }

/* ---------- Leaderboard page ----------------------------------- */
.lb-page { padding-bottom: 40px; }
.lb-tabs-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 0; }
.lb-tabs {
    display: flex;
    gap: 6px;
    padding: 4px;
    background: var(--bg-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    width: max-content;
    min-width: 100%;
}
.lb-tab {
    padding: 8px 14px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .82rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, color .12s;
}
.lb-tab.active { background: var(--bg-3); color: var(--text); }
.leaderboard-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

/* ---------- Modal --------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    display: grid;
    place-items: center;
    padding: 16px;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 580px;
    max-height: 90dvh;
    overflow-y: auto;
    box-shadow: var(--shadow-card);
    animation: modalIn .18s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(.96) translateY(6px); }
    to   { opacity: 1; transform: none; }
}
.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border-soft);
    position: sticky;
    top: 0;
    background: var(--bg-1);
    z-index: 1;
}
.modal-head h3 { margin: 0 0 4px; }
.modal-close {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border: none;
    background: var(--bg-2);
    color: var(--text-muted);
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background .1s, color .1s;
}
.modal-close:hover { background: var(--bg-3); color: var(--text); }
.modal-body { padding: 18px 22px 24px; }

/* Modal muscle score */
.modal-muscle-score { margin-bottom: 16px; }
.modal-score-val { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 8px; }

/* Modal exercise list */
.modal-section-title {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 16px 0 10px;
}
.modal-ex-list { display: flex; flex-direction: column; gap: 10px; }
.modal-ex-row {
    background: var(--bg-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 12px 14px;
}
.modal-ex-row--best {
    border-color: rgba(110,231,255,.3);
    background: rgba(110,231,255,.04);
}
.modal-ex-name {
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.modal-ex-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: .85rem;
    margin: 4px 0 6px;
    color: var(--text-muted);
}
.modal-ex-empty {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.modal-ex-empty li {
    padding: 8px 12px;
    background: var(--bg-2);
    border-radius: var(--radius-sm);
    font-size: .88rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-form-wrap {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
}
.modal-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.modal-form-actions a { padding: 12px 20px; border-radius: var(--radius); font-weight: 600; font-size: .95rem; }

/* ---------- Exercise progress bars ----------------------------- */
.ex-progress-wrap { margin: 6px 0 2px; }
.ex-progress-label {
    display: flex;
    justify-content: space-between;
    font-size: .75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.ex-progress-bar {
    height: 5px;
    background: var(--bg-3);
    border-radius: 999px;
    overflow: hidden;
}
.ex-progress-fill {
    height: 100%;
    border-radius: 999px;
    transition: width .5s ease;
}

/* ---------- Badges -------------------------------------------- */
.badge-best {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(110,231,255,.15);
    border: 1px solid rgba(110,231,255,.3);
    color: var(--accent);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .04em;
}
.badge-principal {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: .7rem;
    letter-spacing: .04em;
}

/* ---------- Bar hint ------------------------------------------ */
.bar-hint {
    padding: 6px 10px;
    background: var(--bg-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    margin: -6px 0 10px;
}

/* ---------- Muscle detail page --------------------------------- */
.detail-head {
    background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    margin-bottom: 24px;
}
.back-btn { margin-bottom: 12px; display: inline-flex; }
.detail-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.detail-title h2 { margin: 0; }
.detail-score { display: flex; align-items: baseline; gap: 4px; margin-bottom: 6px; }
.detail-prog { height: 8px; margin: 4px 0; }

.ex-section { margin-bottom: 28px; }
.ex-card {
    background: var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    margin-bottom: 14px;
}
.ex-card--best {
    border-color: rgba(110,231,255,.25);
    background: rgba(110,231,255,.03);
}
.ex-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.ex-card-head h4 { margin: 0 0 2px; }
.ex-card-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}
.stat { text-align: center; padding: 8px; background: var(--bg-2); border-radius: var(--radius-sm); }
.stat-val { display: block; font-weight: 700; font-size: .95rem; }
.stat-lbl { font-size: .72rem; color: var(--text-muted); display: block; margin-top: 2px; }
.ex-history { margin-top: 14px; }
.ex-history-toggle {
    font-size: .82rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}
.ex-history-toggle:hover { color: var(--text); }
.ex-actions { white-space: nowrap; }
.btn-icon {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--bg-2);
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: .85rem;
    transition: background .1s, color .1s;
}
.btn-icon:hover { background: var(--bg-3); color: var(--text); }
.btn-icon--danger:hover { background: rgba(239,68,68,.15); color: var(--danger); border-color: var(--danger); }

.add-perf-section { margin-bottom: 40px; }

/* ---------- Theme picker (profile) ----------------------------- */
.theme-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}
.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border: 2px solid var(--border-soft);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color .12s;
    font-size: .8rem;
    color: var(--text-muted);
}
.theme-option input[type="radio"] { display: none; }
.theme-option--active,
.theme-option:hover {
    border-color: var(--accent);
    color: var(--text);
}
.theme-swatch {
    display: flex;
    gap: 4px;
}
.theme-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,.15);
}
.theme-name { font-weight: 600; }

/* ---------- Responsive tweaks ---------------------------------- */
@media (max-width: 520px) {
    .topbar { padding: 12px; }
    .brand-name { display: none; }
    .nav a { font-size: .85rem; }
    .auth-card { padding: 22px; }
    .dash-head { padding: 16px; }
    .score-value { font-size: 1.8rem; }
    .history-table { font-size: .8rem; }
    .history-table th:nth-child(1), .history-table td:nth-child(1) { display: none; }
}

/* =====================================================================
   MANNEQUIN 3D — manikin.js
   ===================================================================== */

/* Conteneur principal */
.manikin-stage {
    aspect-ratio: 4 / 5;
    min-height: 480px;
    background: var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}
@media (max-width: 720px) {
    .manikin-stage { aspect-ratio: 3 / 4; min-height: 360px; }
}

/* Score global (overlay haut-gauche) */
.mn-score-box {
    position: absolute;
    top: 14px;
    left: 14px;
    background: rgba(17, 20, 28, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 14px;
    z-index: 5;
    line-height: 1.3;
    pointer-events: none;
}
.mn-score-box small { font-size: .65rem; letter-spacing: .08em; color: var(--text-muted); }
.mn-score-val {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    margin: 2px 0 4px;
}

/* Toggle avant/arrière (haut centre) */
.mn-toggle {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0;
    background: rgba(17, 20, 28, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    z-index: 5;
}
.mn-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: .8rem;
    padding: 6px 14px;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.mn-toggle-btn.active,
.mn-toggle-btn:hover {
    background: var(--bg-3);
    color: var(--text);
}

/* Légende bas */
.mn-legend {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 6px 10px;
    background: rgba(17, 20, 28, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 20px;
    z-index: 5;
    max-width: 95%;
    scrollbar-width: none;
    pointer-events: none;
}
.mn-legend::-webkit-scrollbar { display: none; }
.mn-leg-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .68rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.mn-leg-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.mn-dot-untrained { background: #6b7280; }
.mn-dot-bronze    { background: #b06a3b; }
.mn-dot-silver    { background: #c5cbd6; }
.mn-dot-gold      { background: #f0b429; }
.mn-dot-platinum  { background: #7fd1e4; }
.mn-dot-diamond   { background: #6ea8ff; }
.mn-dot-master    { background: #d96cff; }
.mn-dot-legend    { background: #ff4d6d; }

/* Bouton reset vue (bas droite) */
.mn-reset-btn {
    position: absolute;
    bottom: 14px;
    right: 14px;
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(17, 20, 28, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: color .15s, background .15s;
}
.mn-reset-btn:hover { color: var(--text); background: var(--bg-3); }

/* Tooltip */
.mn-tooltip {
    position: absolute;
    background: rgba(17, 20, 28, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: .8rem;
    color: var(--text);
    line-height: 1.4;
    pointer-events: none;
    z-index: 10;
    transition: opacity .15s;
    max-width: 200px;
}
.tt-score { color: var(--text-muted); font-size: .75rem; }
.tt-untrained { color: #6b7280; }
.tt-bronze    { color: #b06a3b; }
.tt-silver    { color: #c5cbd6; }
.tt-gold      { color: #f0b429; }
.tt-platinum  { color: #7fd1e4; }
.tt-diamond   { color: #6ea8ff; }
.tt-master    { color: #d96cff; }
.tt-legend    { color: #ff4d6d; }
