:root {
  --bg: #0e1013;
  --bg-elev: #16191d;
  --bg-elev2: #1c2026;
  --border: #292f37;
  --border-soft: #21262d;
  --text: #f2f4f7;
  --muted: #8b95a1;
  --muted-dim: #5f6873;
  --accent: #ee5a34;
  --accent-press: #d1471f;
  --ok: #46b981;
  --danger: #e05540;
  --radius: 14px;
  --radius-sm: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

.ic { display: block; flex: none; }

/* ---------- Layout ---------- */
#app { max-width: 620px; margin: 0 auto; min-height: 100vh; }
.screen { padding: calc(var(--safe-t) + 18px) 18px calc(100px + var(--safe-b)); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 20px; }
.topbar h1 { font-size: 24px; margin: 0; letter-spacing: -0.5px; font-weight: 700; }
.topbar .sub { font-size: 13px; color: var(--muted); margin-top: 3px; }

.room-chip {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 11px; font-size: 12.5px; color: var(--muted);
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.room-chip b { color: var(--text); font-weight: 600; }

/* ---------- Cards / listes ---------- */
.card {
  background: var(--bg-elev); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card-row { display: flex; align-items: center; gap: 12px; }
.card-row .grow { flex: 1; min-width: 0; }
.card h3 { margin: 0 0 4px; font-size: 17px; }
.card .meta { color: var(--muted); font-size: 13px; }

.list-item {
  display: flex; align-items: center; gap: 13px;
  background: var(--bg-elev); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 15px 16px; margin-bottom: 10px;
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item h3 { margin: 0; font-size: 16px; font-weight: 600; }
.list-item .meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.chevron { color: var(--muted-dim); }

/* ---------- Boutons ---------- */
.btn {
  border: none; border-radius: var(--radius-sm); padding: 15px 18px;
  font-size: 15px; font-weight: 600; color: #fff; background: var(--accent);
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { background: var(--accent-press); }
.btn-secondary { background: var(--bg-elev2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:active { background: var(--bg-elev); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--muted); border: none; font-size: 14px; padding: 12px; }
.icon-btn {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--muted);
  width: 40px; height: 40px; border-radius: var(--radius-sm); flex: none;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: var(--bg-elev2); }

/* ---------- Champs ---------- */
.field { margin-bottom: 13px; }
.field label {
  display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 7px;
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
}
.input {
  width: 100%; background: var(--bg-elev2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; color: var(--text); font-size: 16px;
}
.input:focus { outline: none; border-color: var(--accent); }
.row-inputs { display: flex; gap: 9px; }
.row-inputs .field { flex: 1; margin-bottom: 0; }

/* ---------- Nav basse ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(14,16,19,0.94); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-soft);
  display: flex; padding: 9px 8px calc(9px + var(--safe-b));
  max-width: 620px; margin: 0 auto;
}
.nav button {
  background: none; border: none; color: var(--muted-dim);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500; padding: 5px 0; border-radius: 10px; flex: 1;
}
.nav button.active { color: var(--accent); }
.nav .ico { line-height: 0; }

/* ---------- Empty state ---------- */
.empty { text-align: center; color: var(--muted); padding: 60px 24px; font-size: 14.5px; line-height: 1.6; }
.empty .big { color: var(--muted-dim); margin-bottom: 14px; display: flex; justify-content: center; }

/* ---------- Séance ---------- */
.exo {
  background: var(--bg-elev); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px; transition: opacity .2s;
}
.exo-top { display: flex; align-items: center; gap: 14px; }
.exo.done { opacity: 0.5; }
.exo.done .exo-name { text-decoration: line-through; text-decoration-color: var(--muted-dim); }
.check {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  border: 1.5px solid var(--border); background: transparent;
  display: flex; align-items: center; justify-content: center; color: transparent;
}
.exo.done .check { background: var(--ok); border-color: var(--ok); color: #07130c; }
.exo .grow { flex: 1; min-width: 0; }
.exo-name { font-size: 16px; font-weight: 600; }
.exo-meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.exo-meta .by { color: var(--accent); font-weight: 500; }
.rest-btn {
  background: var(--bg-elev2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 11px; font-size: 13px; font-weight: 600; flex: none;
  display: flex; align-items: center; gap: 6px;
}
.rest-btn .ic { color: var(--accent); }

/* Séries (compteur + repos entre séries) */
.sets-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.pips { display: flex; gap: 6px; }
.pip { width: 10px; height: 10px; border-radius: 50%; background: var(--bg-elev2); border: 1px solid var(--border); transition: background .2s; }
.pip.on { background: var(--accent); border-color: var(--accent); }
.set-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-elev2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 14px; font-weight: 600;
}
.set-btn:active { background: var(--bg-elev); }
.set-btn:disabled { opacity: .5; }
.set-btn .ic { color: var(--accent); }
.set-rest { color: var(--muted); font-weight: 500; margin-left: 2px; }

/* Charges par participant */
.perfs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.perf-me {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-elev2); border: 1px solid var(--border); border-radius: 9px; padding: 7px 11px;
}
.perf-name { font-size: 12px; font-weight: 600; color: var(--accent); }
.perf-input { width: 68px; background: transparent; border: none; color: var(--text); font-size: 15px; font-weight: 600; padding: 0; }
.perf-input:focus { outline: none; }
.perf-input::placeholder { color: var(--muted-dim); font-weight: 500; }
.perf-hint { font-size: 11px; color: var(--muted-dim); white-space: nowrap; }
.perf-chip {
  font-size: 12.5px; color: var(--muted); font-weight: 500;
  background: var(--bg-elev2); border: 1px solid var(--border-soft); border-radius: 9px; padding: 8px 11px;
}

.progress { height: 6px; background: var(--bg-elev2); border-radius: 999px; overflow: hidden; margin: 14px 0 0; }
.progress > div { height: 100%; background: var(--accent); transition: width .35s ease; }

/* ---------- Overlay timer ---------- */
.rest-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(9,11,13,0.94); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.rest-card { text-align: center; width: 100%; max-width: 340px; }
.rest-label { color: var(--muted); text-transform: uppercase; letter-spacing: 3px; font-size: 12px; font-weight: 600; }
.rest-time { font-size: 74px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 6px 0 2px; letter-spacing: -2px; }
.rest-ex { color: var(--accent); font-size: 15px; min-height: 20px; margin-bottom: 22px; font-weight: 500; }
.rest-ring-wrap { position: relative; width: 200px; height: 200px; margin: 0 auto 26px; }
.rest-ring { position: absolute; inset: 0; transform: rotate(-90deg); width: 200px; height: 200px; }
.rest-ring-bg { fill: none; stroke: var(--bg-elev2); stroke-width: 7; }
.rest-ring-fg {
  fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round;
  stroke-dasharray: 339.29; stroke-dashoffset: 0; transition: stroke-dashoffset .95s linear;
}
.rest-actions { display: flex; gap: 12px; justify-content: center; margin-bottom: 14px; }
.btn-round {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 12px 22px; font-size: 15px; font-weight: 600;
}
.btn-round:active { background: var(--bg-elev2); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: calc(96px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  background: var(--bg-elev2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: var(--radius-sm); font-size: 14px; z-index: 80;
  max-width: 90%; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.45);
}

/* ---------- Login ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 28px; }
.brandmark {
  width: 76px; height: 76px; border-radius: 20px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; color: #fff;
}
.login h1 { text-align: center; margin: 0 0 6px; font-size: 27px; letter-spacing: -0.5px; }
.login .lead { text-align: center; color: var(--muted); margin: 0 0 28px; font-size: 14.5px; line-height: 1.55; }
.login .note { margin-top: 16px; font-size: 12px; color: var(--muted-dim); text-align: center; line-height: 1.5; }

.hidden { display: none !important; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 18px; bottom: calc(96px + var(--safe-b)); z-index: 30;
  width: 54px; height: 54px; border-radius: 16px; border: none; color: #fff;
  background: var(--accent); box-shadow: 0 6px 18px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
}
.fab:active { background: var(--accent-press); }

.section-title { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; margin: 22px 4px 11px; }

/* ---------- Modale ---------- */
.modal-back { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.62); display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 18px 18px 0 0; width: 100%; max-width: 620px;
  padding: 22px 18px calc(22px + var(--safe-b)); animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(28px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
.modal h2 { margin: 2px 0 18px; font-size: 19px; letter-spacing: -0.3px; }

/* ---------- Vignettes d'exercice ---------- */
.exo-thumb {
  width: 46px; height: 46px; border-radius: 9px; flex: none; object-fit: cover;
  background: var(--bg-elev2); border: 1px solid var(--border-soft); display: block;
}
.exo-thumb.ph { display: flex; align-items: center; justify-content: center; color: var(--muted-dim); }
.list-item .exo-thumb { cursor: zoom-in; }
.edit-thumb { text-align: center; margin-bottom: 16px; }
.edit-thumb .exo-thumb { width: 120px; height: 120px; border-radius: 12px; margin: 0 auto; }

/* ---------- Sélecteur de catalogue ---------- */
.cat-list { max-height: 60vh; overflow-y: auto; margin-top: 4px; -webkit-overflow-scrolling: touch; }
.cat-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--bg-elev2); border: 1px solid var(--border-soft); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 8px; font-size: 15px; font-weight: 500;
}
.cat-item:active { background: var(--bg-elev); }
.cat-item .exo-thumb { width: 44px; height: 44px; }

/* ---------- Visionneuse (lightbox) ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 90; background: rgba(6,8,10,0.94); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.lb-inner { width: 100%; max-width: 520px; text-align: center; }
.lb-title { font-size: 17px; font-weight: 600; margin-bottom: 14px; }
.lb-imgs { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.lb-imgs img { width: 100%; border-radius: 12px; border: 1px solid var(--border); }
.lb-close { max-width: 200px; margin: 0 auto; }
