/* ============================================================
   Design system 6D Ble tendre
   Fond #121212, accent lime #DAFF7E, accent ambre #CC8830
   Titres Outfit 800, donnees chiffrees Space Mono
   Polices auto-hebergees : aucune requete reseau, l'app doit
   s'afficher correctement en salle sans data.
   ============================================================ */

@font-face {
  font-family: 'Outfit';
  src: url('/fonts/outfit-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Space Mono';
  src: url('/fonts/spacemono-400-latin.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Space Mono';
  src: url('/fonts/spacemono-700-latin.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #121212;
  --surface: #1B1B1B;
  --surface-2: #242424;
  --line: #2E2E2E;
  --text: #F2F2F2;
  --muted: #8E8E8E;
  --lime: #DAFF7E;
  --amber: #CC8830;
  --danger: #E4574A;
  --ink: #121212;

  --radius: 14px;
  --pad: 16px;
  --tap: 56px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --font-title: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-body: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-mono: 'Space Mono', ui-monospace, SFMono-Regular, monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.35;
  overscroll-behavior-y: none;
}

body { -webkit-text-size-adjust: 100%; }

h1, h2, h3 { font-family: var(--font-title); font-weight: 800; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 30px; text-transform: uppercase; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }

.num { font-family: var(--font-mono); font-weight: 700; font-variant-numeric: tabular-nums; }

.app {
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 12px) var(--pad) calc(var(--safe-bottom) + 96px);
  max-width: 560px;
  margin: 0 auto;
}
.boot { color: var(--muted); padding: 40px 0; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.mono { font-family: var(--font-mono); }
.lime { color: var(--lime); }
.amber { color: var(--amber); }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.row-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }

/* ---------- header ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  min-height: 40px;
}
.topbar h1, .topbar h2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back {
  width: 40px; height: 40px; flex: none;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font-size: 20px; line-height: 1;
}

.pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok { color: var(--lime); border-color: #3C4A28; }
.pill.warn { color: var(--amber); border-color: #4A3A20; }
.pill.bad { color: var(--danger); border-color: #4A2622; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.card + .card { margin-top: 10px; }
.card-title { font-family: var(--font-title); font-weight: 800; font-size: 18px; }

.banner {
  border-radius: var(--radius);
  padding: 12px 14px;
  border: 1px solid var(--amber);
  background: rgba(204, 136, 48, 0.12);
  color: #F0D3AB;
  font-size: 15px;
}
.banner.info { border-color: var(--line); background: var(--surface); color: var(--muted); }
.banner.bad { border-color: var(--danger); background: rgba(228, 87, 74, 0.12); color: #F3C0BB; }

/* ---------- boutons ---------- */
button {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  min-height: var(--tap);
  cursor: pointer;
}
button:active { transform: scale(0.985); }
button:disabled { opacity: 0.4; }

.btn-primary {
  background: var(--lime);
  color: var(--ink);
  border-color: var(--lime);
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.btn-amber { background: var(--amber); color: var(--ink); border-color: var(--amber); font-weight: 700; }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: #4A2622; }
.btn-block { width: 100%; }
.btn-sm { min-height: 42px; font-size: 14px; padding: 0 12px; }

/* barre d'action collee en bas : utilisation a une main */
.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 10px var(--pad) calc(var(--safe-bottom) + 10px);
  background: linear-gradient(180deg, rgba(18,18,18,0) 0%, var(--bg) 26%);
  display: flex;
  gap: 10px;
  max-width: 560px;
  margin: 0 auto;
  z-index: 20;
}
.actionbar > * { flex: 1; }
.actionbar > .flex-none { flex: none; }

/* ---------- accueil ---------- */
.session-btn {
  width: 100%;
  text-align: left;
  padding: 16px;
  min-height: 76px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--lime);
}
.session-btn .t { font-family: var(--font-title); font-weight: 800; font-size: 19px; display: block; }
.session-btn .s { color: var(--muted); font-size: 13px; font-family: var(--font-mono); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  min-height: 76px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; font-size: 13px; font-weight: 600;
  background: var(--surface);
}
.tile .g { font-size: 20px; line-height: 1; }

/* ---------- seance ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin: 0 calc(var(--pad) * -1); padding-left: var(--pad); padding-right: var(--pad); }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 38px; padding: 0 12px; font-size: 13px;
  border-radius: 999px; background: var(--surface); color: var(--muted);
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip.active { background: var(--lime); color: var(--ink); border-color: var(--lime); font-weight: 700; }
.chip.done { color: var(--lime); border-color: #3C4A28; }

.setlist { display: flex; flex-direction: column; gap: 6px; }
.setline {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; background: var(--surface-2);
  font-family: var(--font-mono); font-size: 14px;
}
.setline .idx { color: var(--muted); width: 20px; }
.setline.pending { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.setline.current { border: 1px solid var(--lime); background: rgba(218,255,126,0.08); color: var(--text); }

.stepper { display: flex; align-items: stretch; gap: 8px; }
.stepper button { width: 64px; flex: none; font-size: 26px; font-weight: 700; padding: 0; }
.stepper .val {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  min-height: var(--tap);
}
.stepper input {
  width: 100%; text-align: center; background: transparent; border: 0; color: var(--text);
  font-family: var(--font-mono); font-weight: 700; font-size: 26px; padding: 0;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .unit { color: var(--muted); font-size: 14px; font-family: var(--font-mono); padding-right: 10px; }
.field-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }

.rpe { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rpe button { font-family: var(--font-mono); font-weight: 700; font-size: 20px; padding: 0; }
.rpe button.on { background: var(--amber); color: var(--ink); border-color: var(--amber); }

details.rpe-guide { margin-top: 10px; }
details.rpe-guide summary {
  list-style: none; cursor: pointer; color: var(--lime); font-size: 14px;
  padding: 10px 0; min-height: 40px; display: flex; align-items: center;
}
details.rpe-guide summary::-webkit-details-marker { display: none; }
details.rpe-guide .body { font-family: var(--font-mono); font-size: 13px; color: var(--muted); line-height: 1.9; }

textarea, input[type="text"], input[type="date"], input[type="url"], input[type="password"] {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; color: var(--text); padding: 12px;
  font-family: var(--font-body); font-size: 16px; min-height: var(--tap);
}
textarea { min-height: 110px; resize: vertical; font-family: var(--font-mono); font-size: 14px; }
input[type="date"] { font-family: var(--font-mono); }

/* ---------- overlay plein ecran (repos, emom, routine) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 20px) var(--pad) calc(var(--safe-bottom) + 20px);
}
.overlay .ov-top { color: var(--muted); font-family: var(--font-mono); font-size: 14px; text-align: center; }
.overlay .ov-label {
  font-family: var(--font-title); font-weight: 800; font-size: 30px; text-align: center;
  margin-top: 6px; line-height: 1.1;
}
.overlay .ov-mid { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.overlay .ov-count {
  font-family: var(--font-mono); font-weight: 700; font-size: 96px; line-height: 1;
  color: var(--lime); font-variant-numeric: tabular-nums;
}
.overlay.prep .ov-count { color: var(--amber); }
.overlay .ov-next { color: var(--muted); margin-top: 14px; text-align: center; font-size: 16px; }
.overlay .ov-actions { display: flex; gap: 10px; }
.overlay .ov-actions > * { flex: 1; }
.progressbar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 18px; }
.progressbar > div { height: 100%; background: var(--lime); width: 0; }

/* ---------- modal ---------- */
.modal-root {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: flex-end; justify-content: center;
  padding: var(--pad);
  padding-bottom: calc(var(--safe-bottom) + var(--pad));
}
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; width: 100%; max-width: 528px; max-height: 86dvh; overflow: auto;
}
.modal h2 { margin-bottom: 8px; }
.modal .modal-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* ---------- listes ---------- */
.list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
}
.list-item + .list-item { margin-top: 8px; }
.list-item .id { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.tag {
  font-family: var(--font-mono); font-size: 10px; padding: 3px 6px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}

pre.export {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; max-height: 50dvh; overflow: auto;
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 90px); z-index: 90;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 18px; font-size: 14px; max-width: 90vw; text-align: center;
}
