:root {
  --bg: #140c08;
  --panel: #26140b;
  --panel-2: #341a0d;
  --text: #f6e8d7;
  --muted: #d7b391;
  --accent: #d76a20;
  --accent-2: #ff9f52;
  --danger: #a93d28;
  --ok: #2d9d67;
  --border: rgba(255,255,255,.10);
  --shadow: 0 12px 30px rgba(0,0,0,.25);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: linear-gradient(180deg,#120906,#26120a); color: var(--text); font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif; }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { border: 0; border-radius: 14px; padding: 12px 14px; background: #4a2612; color: var(--text); cursor: pointer; }
button.primary { background: linear-gradient(180deg,var(--accent-2),var(--accent)); color: #1d0b03; font-weight: 800; }
button.success { background: linear-gradient(180deg,#63d59c,var(--ok)); color: #082212; font-weight: 800; }
button:active { transform: translateY(1px); }
input, select, textarea { width: 100%; margin-top: 6px; background: #1a100b; color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
textarea { resize: vertical; }
label { display: block; color: var(--muted); font-size: .96rem; }
.app-shell { width: min(1080px, 100%); margin: 0 auto; padding: env(safe-area-inset-top) 14px calc(24px + env(safe-area-inset-bottom)); }
.hero { display: grid; grid-template-columns: 94px 1fr; gap: 14px; align-items: center; padding: 16px; margin: 10px 0 14px; background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow); }
.hero-logo { width: 94px; height: 94px; object-fit: cover; border-radius: 22px; }
.hero h1 { margin: 0; font-size: 2rem; }
.hero p { margin: 6px 0 0; color: var(--muted); }
.tabs { display: grid; gap: 8px; position: sticky; top: 0; z-index: 5; background: rgba(20,12,8,.92); backdrop-filter: blur(10px); padding-bottom: 8px; }
.tabs-6 { grid-template-columns: repeat(6,1fr); }
.tab { font-size: .9rem; min-width: 0; }
.tab.active { outline: 2px solid var(--accent-2); }
main { display: grid; gap: 14px; }
.panel { display: none; gap: 14px; }
.panel.active { display: grid; }
.card { background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); }
.nested-card { background: rgba(0,0,0,.12); box-shadow: none; }
.cards-grid { display: grid; gap: 12px; }
.stats-grid { grid-template-columns: repeat(3,1fr); }
.stat-card strong { font-size: 2rem; display: block; margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }
.compact-grid { grid-template-columns: repeat(3,1fr); }
.full { grid-column: 1 / -1; }
.inline-actions { display: flex; gap: 10px; align-items: center; }
.wrap-actions { flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }
.title-row { display: flex; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.item-card { background: rgba(0,0,0,.14); border: 1px solid var(--border); border-radius: 18px; padding: 14px; }
.item-card h3, .item-card h4 { margin: 0 0 6px; }
.meta { color: var(--muted); font-size: .92rem; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.tag { background: rgba(255,159,82,.12); border: 1px solid rgba(255,159,82,.28); color: #ffd1ac; padding: 5px 10px; border-radius: 999px; font-size: .84rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.empty-state { border: 1px dashed var(--border); border-radius: 16px; padding: 16px; text-align: center; color: var(--muted); }
.picker-list { display: grid; gap: 10px; }
.picker-item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; background: rgba(0,0,0,.12); padding: 12px; border-radius: 16px; }
.file-label { position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: 14px; background: #4a2612; color: var(--text); }
.file-label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.checkbox-row { display: flex; align-items: center; gap: 10px; }
.checkbox-row input { width: auto; margin: 0; }
.tiny { font-size: .85rem; color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.training-grid { display: grid; gap: 12px; }
.training-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: flex-start; }
.training-session-card { border-left: 4px solid var(--accent-2); }
.training-item { display: grid; gap: 10px; }
.training-item.done { border-left: 4px solid var(--ok); }
.training-item-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; }
.training-fields { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.training-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.kpi-row { display: flex; flex-wrap: wrap; gap: 8px; }
.kpi { background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; }
.status-ok { color: #8cf0ba; }
.status-warn { color: #ffd1ac; }
.small-btn { padding: 8px 10px; border-radius: 10px; }
@media (max-width: 860px) {
  .tabs-6 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .training-fields { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .form-grid, .compact-grid, .stats-grid { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; text-align: center; }
  .hero-logo { margin: 0 auto; }
  .title-row { flex-direction: column; align-items: stretch; }
  .training-fields { grid-template-columns: 1fr; }
}


#trainingCard { display: none; }
#trainingCard.active { display: block; }
.training-header { display: grid; gap: 8px; }
.training-day-list { display: grid; gap: 10px; }
.training-day-card { background: rgba(0,0,0,.12); border: 1px solid var(--border); border-radius: 18px; padding: 14px; }
.training-item { background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: 16px; padding: 12px; display: grid; gap: 10px; }
.training-item.done { border-color: rgba(255,159,82,.45); box-shadow: inset 0 0 0 1px rgba(255,159,82,.18); }
.training-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.training-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.training-kpis { display: flex; flex-wrap: wrap; gap: 8px; }
.training-title-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: #7a3f1e; display: inline-block; }
.status-dot.done { background: var(--accent-2); }
.small-btn { padding: 9px 12px; border-radius: 12px; }
@media (max-width: 760px) {
  .training-grid, .training-grid-2 { grid-template-columns: 1fr; }
}

.top-gap { margin-top: 12px; }


/* === HomeGym V4 Coach IA + Apple Watch mode === */
.tabs-7 { grid-template-columns: repeat(7,1fr); }
.coach-hero-card { border-color: rgba(255,159,82,.35); background: linear-gradient(135deg, rgba(255,159,82,.10), rgba(255,255,255,.035)); }
.coach-advice { background: rgba(0,0,0,.18); border: 1px solid var(--border); border-radius: 18px; padding: 14px; line-height: 1.45; }
.coach-advice strong { color: var(--accent-2); }
.watch-panel { border-color: rgba(99,213,156,.30); }
.watch-face { width: min(360px, 100%); margin: 0 auto; border-radius: 36px; padding: 18px; text-align: center; background: radial-gradient(circle at top, rgba(255,159,82,.18), rgba(0,0,0,.30)); border: 1px solid var(--border); }
.watch-time { font-size: clamp(3rem, 12vw, 5.2rem); font-weight: 900; line-height: 1; letter-spacing: -2px; }
.watch-label { color: var(--muted); margin: 8px 0 14px; }
.watch-actions { justify-content: center; }
.boxing-display { font-size: 1.7rem; font-weight: 900; text-align: center; padding: 18px; border-radius: 18px; background: rgba(0,0,0,.20); border: 1px solid var(--border); }
body.watch-mode .app-shell { width: min(430px, 100%); }
body.watch-mode .hero, body.watch-mode .tabs .tab:not([data-tab="coach"]), body.watch-mode #dashboard, body.watch-mode #exercises, body.watch-mode #sessions, body.watch-mode #programs, body.watch-mode #training, body.watch-mode #backup { display: none !important; }
body.watch-mode .tabs { display: block; position: static; }
body.watch-mode .tab[data-tab="coach"] { width: 100%; display: block; font-size: 1.05rem; }
body.watch-mode .panel { display: none; }
body.watch-mode #coach { display: grid !important; }
body.watch-mode .card { border-radius: 28px; padding: 18px; }
body.watch-mode button { min-height: 52px; font-weight: 800; }
body.watch-mode input, body.watch-mode select, body.watch-mode textarea { font-size: 1.05rem; min-height: 48px; }
@media (max-width: 980px) { .tabs-7 { grid-template-columns: repeat(4, minmax(0,1fr)); } }
@media (max-width: 760px) { .tabs-7 { grid-template-columns: repeat(2, minmax(0,1fr)); } }


/* === Connexion / session HomeGym === */
body.auth-locked { overflow: hidden; }
body.auth-locked .app-shell { display: none; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 22px; background: radial-gradient(circle at top, rgba(255,159,82,.16), rgba(20,12,8,.98) 58%); }
body:not(.auth-locked) .login-screen { display: none; }
.login-card { width: min(440px, 100%); background: rgba(255,255,255,.055); border: 1px solid var(--border); border-radius: 28px; padding: 22px; box-shadow: var(--shadow); text-align: center; }
.login-logo { width: 108px; height: 108px; object-fit: cover; border-radius: 26px; margin-bottom: 10px; }
.login-card h1 { margin: 6px 0; }
.login-card p { color: var(--muted); }
.login-form { display: grid; gap: 12px; text-align: left; margin-top: 14px; }
.login-form button { width: 100%; }
.login-error { min-height: 1.2em; color: #ffd1ac; text-align: center; }
.remember-row { justify-content: flex-start; }
.auth-bar { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin: 0 0 10px; color: var(--muted); }
.auth-bar span { font-size: .9rem; }

/* === Multi-comptes HomeGym V6 === */
.auth-users-list { display: grid; gap: 10px; margin-top: 10px; }
.auth-user-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 16px; background: rgba(255,255,255,.04); }
.auth-user-row > div:first-child { display: grid; gap: 3px; }
.danger-btn { background: rgba(255,70,70,.15); border-color: rgba(255,100,100,.35); }
.danger-btn:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 620px) {
  .auth-user-row { align-items: flex-start; flex-direction: column; }
}
