:root {
  --bg: #F5F4F0;
  --card: #FFFFFF;
  --soft: #EFEDE7;
  --line: #E3E0D8;
  --text: #17181C;
  --muted: #6B6A66;
  --accent: #FF5A1F;
  --accent-soft: #FFE8DE;
  --accent-text: #B83A0B;
  --ok: #1E9E62;
  --ok-soft: #DDF3E8;
  --drop: #FFF3D6;
  --drop-text: #8A5A00;
  --rest: #2F6FDB;
  --rest-soft: #E1ECFC;
  --danger: #D33A3A;
  --radius: 14px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }

.screen { max-width: 560px; margin: 0 auto; padding: 0 16px calc(var(--nav-h) + var(--safe-b) + 24px); min-height: 100vh; }
.screen.no-nav { padding-bottom: 32px; }

.top { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 14px) 0 12px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.top h1 { font-size: 22px; font-weight: 700; margin: 0; flex: 1; letter-spacing: -0.01em; }
.top h1.small { font-size: 18px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: none; background: var(--card); display: inline-flex; align-items: center; justify-content: center; font-size: 20px; cursor: pointer; flex-shrink: 0; }
.icon-btn.ghost { background: transparent; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0; border: none; cursor: pointer; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.card.tap { cursor: pointer; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.bold { font-weight: 600; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 18px 2px 8px; }
.spacer { height: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; border-radius: 12px; padding: 12px 16px; font-weight: 600; cursor: pointer; background: var(--card); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.dark { background: var(--text); color: #fff; }
.btn.soft { background: var(--soft); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.danger { background: transparent; color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: 0.5; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 12px; outline: none; }
.input:focus { border-color: var(--accent); }
.num { width: 58px; text-align: center; border: 1px solid var(--line); border-radius: 10px; padding: 7px 4px; background: var(--card); outline: none; }
.num:focus { border-color: var(--accent); }
.num.wide { width: 72px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { border: none; border-radius: 999px; padding: 7px 13px; background: var(--card); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--text); color: #fff; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }
.tag.drop { background: var(--drop); color: var(--drop-text); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.rest { background: var(--rest-soft); color: var(--rest); }

.thumb { border-radius: 10px; background: var(--soft); object-fit: cover; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); overflow: hidden; }

/* Semaine */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 14px; }
.day { border: none; background: transparent; border-radius: 12px; padding: 8px 0; text-align: center; cursor: pointer; }
.day .d { font-size: 12px; color: var(--muted); }
.day .n { font-size: 16px; font-weight: 600; margin-top: 2px; }
.day .dot { height: 6px; margin-top: 4px; display: flex; justify-content: center; gap: 3px; }
.day .dot i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); display: block; }
.day .dot i.done { background: var(--ok); }
.day .dot i.plan { background: var(--accent); }
.day.out .n { color: var(--line); }
.month { padding: 10px 8px; }
.month .day { padding: 5px 0; }
.month .day .n { font-size: 15px; margin-top: 0; }
.day.on { background: var(--text); }
.day.on .d, .day.on .n { color: #fff; }
.day.today:not(.on) .n { color: var(--accent); }

/* Séance */
.set { border-top: 1px solid var(--line); padding: 9px 0; }
.set:first-of-type { border-top: none; }
.set.done { opacity: 0.6; }
.step { display: flex; align-items: center; gap: 5px; padding: 3px 0; }
.step .lab { width: 14px; font-size: 12px; color: var(--muted); }
.step .num { width: 54px; }
.multi { background: var(--drop); border-radius: 10px; padding: 6px 8px; flex: 1; min-width: 0; }
.check { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; color: transparent; font-size: 18px; }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.superset-link { font-size: 12px; color: var(--accent-text); display: flex; align-items: center; gap: 4px; margin: -4px 0 8px 14px; }

/* Éditeur de série */
.group { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.group-step { display: flex; align-items: center; gap: 6px; padding: 5px 0; flex-wrap: wrap; }
.group-step .k { font-size: 12px; font-weight: 600; width: 58px; }

/* Barre du bas */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 20; }
.nav-in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); height: var(--nav-h); }
.nav button { border: none; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); cursor: pointer; }
.nav button i { font-size: 23px; }
.nav button.on { color: var(--accent); font-weight: 600; }

.fab-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(10px + var(--safe-b)); background: linear-gradient(transparent, var(--bg) 30%); z-index: 15; }
.fab-bar .in { max-width: 528px; margin: 0 auto; }

/* Feuille modale */
.sheet-bg { position: fixed; inset: 0; background: rgba(20,20,20,0.4); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 16px 16px calc(20px + var(--safe-b)); }
.sheet h2 { font-size: 18px; margin: 0 0 12px; }

/* Minuteur */
.run { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; color: #fff; padding: calc(env(safe-area-inset-top, 0px) + 14px) 20px calc(24px + var(--safe-b)); transition: background 0.3s; }
.run.work { background: var(--accent); }
.run.rest { background: var(--rest); }
.run.prep { background: #3A3A40; }
.run.end { background: var(--ok); }
.run .phase { font-size: 18px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.9; }
.run .big { font-size: min(34vw, 190px); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; text-align: center; margin: auto 0 8px; }
.run .exname { font-size: 26px; font-weight: 700; text-align: center; }
.run .next { text-align: center; opacity: 0.85; margin-top: 6px; font-size: 15px; }
.run .bar { height: 6px; background: rgba(255,255,255,0.3); border-radius: 3px; overflow: hidden; margin: 18px 0 22px; }
.run .bar i { display: block; height: 100%; background: #fff; }
.run .ctrls { display: flex; justify-content: center; gap: 18px; }
.run .ctrls button { width: 64px; height: 64px; border-radius: 50%; border: none; background: rgba(255,255,255,0.22); color: #fff; font-size: 28px; cursor: pointer; }
.run .ctrls button.main { width: 84px; height: 84px; background: #fff; color: var(--text); font-size: 36px; }
.run .runimg { width: 150px; height: 110px; border-radius: 14px; margin: 12px auto 0; object-fit: cover; background: rgba(255,255,255,0.2); }

/* Graphique */
.chart { width: 100%; height: 160px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 12px 14px; }
.stat .v { font-size: 24px; font-weight: 700; margin-top: 2px; }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty i { font-size: 36px; display: block; margin-bottom: 8px; }
.banner { background: var(--rest-soft); color: var(--rest); border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
