/* Palette encre / os / rouille / sarcelle — mode sombre d'abord */
:root {
  --ink: #14171a;
  --ink-2: #1c2024;
  --ink-3: #262b31;
  --line: #333a42;
  --bone: #ece6da;
  --bone-dim: #a9a397;
  --rust: #d4683a;
  --teal: #2fa59a;
  --ok: #6cc26a;
  --warn: #e0b341;
  --accent: var(--rust);
  --radius: 16px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-title: "Archivo", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}
body { --timer-rest: var(--teal); --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent); }
body.p-marine { --accent: var(--teal); --timer-rest: var(--rust); --accent-soft: color-mix(in srgb, var(--teal) 18%, transparent); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
h1, h2, h3 { font-family: var(--font-title); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 900; }
h2 { font-size: 1.2rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 800; }
p { margin: 0.4em 0; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
small, .muted { color: var(--bone-dim); }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.topbar .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--ink);
  font-family: var(--font-title); font-weight: 900;
}
.topbar .who-text { min-width: 0; }
.topbar .who-name { font-family: var(--font-title); font-weight: 800; }
.topbar .who-sub { font-size: 0.8rem; color: var(--bone-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.view {
  padding: 16px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px);
  max-width: 640px; margin: 0 auto;
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--ink-2);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--bone-dim); text-decoration: none; font-size: 0.72rem; font-weight: 600;
}
.tabbar a .ico { font-size: 1.35rem; line-height: 1; }
.tabbar a.active { color: var(--accent); }

/* ---------- Generic ---------- */
.card {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px;
  background: var(--ink-3); color: var(--bone-dim);
  font-size: 0.8rem; font-weight: 600;
}
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--ink-3); font-weight: 700; cursor: pointer;
  text-decoration: none; color: var(--bone);
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 0.9rem; border-radius: 10px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--ink-3);
  display: grid; place-items: center; cursor: pointer; font-size: 1.1rem;
}
.icon-btn.on { background: var(--accent); color: var(--ink); border-color: var(--accent); }

.seg { display: flex; background: var(--ink-3); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button {
  flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent;
  font-weight: 700; color: var(--bone-dim); cursor: pointer;
}
.seg button.on { background: var(--accent); color: var(--ink); }

input, select, textarea {
  font: inherit; color: var(--bone);
  background: var(--ink-3); border: 1px solid var(--line); border-radius: 10px;
  min-height: 44px; padding: 8px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: block; }
label.field > span { display: block; font-size: 0.8rem; color: var(--bone-dim); margin-bottom: 4px; font-weight: 600; }

.section-title { margin: 22px 0 10px; display: flex; align-items: baseline; justify-content: space-between; }
.section-title small { font-weight: 500; }
.note {
  border-left: 3px solid var(--accent); padding: 8px 12px; background: var(--ink-2);
  border-radius: 0 10px 10px 0; color: var(--bone-dim); font-size: 0.9rem;
}

/* ---------- Profile picker ---------- */
.pick { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: 24px 16px; max-width: 520px; margin: 0 auto; }
.pick h1 { font-size: 2.4rem; }
.pick-card {
  display: flex; align-items: center; gap: 16px;
  padding: 22px; border-radius: 20px; text-decoration: none; color: var(--bone);
  background: var(--ink-2); border: 1px solid var(--line);
}
.pick-card .avatar { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font: 900 1.8rem var(--font-title); color: var(--ink); }
.pick-card h2 { font-size: 1.5rem; }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-head h2 { text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 0.75rem; color: var(--bone-dim); font-weight: 700; padding-bottom: 4px; }
.cal-day {
  aspect-ratio: 1; border-radius: 12px; border: 1px solid transparent;
  background: var(--ink-2); display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; cursor: pointer; position: relative; padding: 0;
}
.cal-day.out { opacity: 0.3; }
.cal-day.planned { border-color: var(--accent); border-style: dashed; }
.cal-day.done { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.cal-day.today { box-shadow: 0 0 0 2px var(--bone) inset; }
.cal-day.sel { outline: 3px solid var(--bone); outline-offset: 1px; }
.cal-day .tag { font-size: 0.62rem; font-weight: 800; line-height: 1; margin-top: 2px; opacity: 0.85; }
.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 0.8rem; color: var(--bone-dim); }
.cal-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }

.streak { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--ink-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat b { display: block; font: 900 1.6rem var(--font-title); }
.stat span { font-size: 0.75rem; color: var(--bone-dim); }

/* ---------- Session ---------- */
.steps { display: flex; gap: 6px; margin: 10px 0 16px; }
.steps div { flex: 1; height: 6px; border-radius: 3px; background: var(--ink-3); }
.steps div.on { background: var(--accent); }

.ex { padding: 0; overflow: hidden; }
.ex.complete { border-color: var(--ok); }
.ex-fig { background: var(--ink-3); position: relative; }
.ex-fig svg { display: block; width: 100%; height: 150px; }
.ex-fig .fig-label { position: absolute; top: 8px; left: 10px; }
.ex-fig .fig-demo { position: absolute; top: 8px; right: 10px; }
.ex-body { padding: 14px 16px 16px; }
.ex-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.ex-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.ex-big { font: 900 1.5rem var(--font-title); }
.ex-big small { font: 600 0.85rem var(--font-body); }

.sets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.set {
  min-width: 56px; min-height: 56px; border-radius: 14px; flex: 1;
  border: 2px solid var(--line); background: var(--ink-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; cursor: pointer; font-size: 1.05rem; padding: 4px;
}
.set small { font-size: 0.68rem; font-weight: 600; }
.set.done { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.set.done small { color: var(--ink); }
.set-pair { display: flex; gap: 4px; flex: 1; }
.set-pair .set { min-width: 0; }

.log-row { display: grid; grid-template-columns: 34px 1fr 1fr; gap: 8px; align-items: center; margin-top: 6px; }
.log-row input { min-height: 40px; padding: 6px 10px; }
.tips { margin: 10px 0 0; padding-left: 20px; color: var(--bone-dim); font-size: 0.92rem; }
.tips li + li { margin-top: 4px; }
details summary { cursor: pointer; font-weight: 700; color: var(--accent); margin-top: 10px; }

.check-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.check-item:last-child { border-bottom: 0; }
.check-box { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-weight: 900; }
.check-item.done .check-box { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.check-item.done .check-text { color: var(--bone-dim); text-decoration: line-through; }

.pain { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; }
.pain button { aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line); background: var(--ink-3); font-weight: 800; cursor: pointer; padding: 0; }
.pain button.on { background: var(--accent); color: var(--ink); border-color: var(--accent); }

.suggest { border-color: var(--warn); }
.suggest .chip { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

/* ---------- Timers ---------- */
.timers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.timer {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.timer.running { border-color: var(--accent); }
.timer.rest.running { border-color: var(--teal); }
body.p-marine .timer.rest.running { border-color: var(--rust); }
.timer.alarm { background: var(--accent); color: var(--ink); cursor: pointer; }
.timer.alarm .t-sub, .timer.alarm .timer-label { color: var(--ink); }
.timer-label { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--bone-dim); }
.timer-ring { position: relative; width: 100%; max-width: 170px; aspect-ratio: 1; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring .t-val {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: 900 clamp(1.7rem, 9vw, 2.6rem) var(--font-title); font-variant-numeric: tabular-nums;
}
.timer-ring .t-sub { font: 700 0.75rem var(--font-body); color: var(--bone-dim); margin-top: 2px; text-align: center; padding: 0 6px; }
.timer-ctrl { display: flex; gap: 6px; width: 100%; }
.timer-ctrl .btn { flex: 1; min-height: 44px; padding: 0 6px; }
.timer-presets { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.timer-presets button { border: 1px solid var(--line); background: var(--ink-3); border-radius: 8px; padding: 4px 8px; font-size: 0.8rem; font-weight: 700; cursor: pointer; }

.timers.mini { position: sticky; top: 64px; z-index: 15; margin: 0 -4px 12px; }
.timers.mini .timer { flex-direction: row; padding: 8px 10px; gap: 8px; background: color-mix(in srgb, var(--ink-2) 95%, transparent); backdrop-filter: blur(6px); }
.timers.mini .t-mini-val { font: 900 1.6rem var(--font-title); font-variant-numeric: tabular-nums; flex: 1; }
.timers.mini .timer-label { font-size: 0.62rem; }
.timers.mini .icon-btn { width: 36px; height: 36px; }

/* ---------- Charts ---------- */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart text { fill: var(--bone-dim); font-size: 10px; font-family: var(--font-body); }
.chart .lbl { fill: var(--bone); font-weight: 700; font-size: 11px; }
.chart .series { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); stroke: var(--ink-2); stroke-width: 2; }
.chart .goal { stroke: var(--ok); stroke-dasharray: 5 4; stroke-width: 1.5; }
.chart .goal-t { fill: var(--ok); font-weight: 700; }
.chart .bar { fill: var(--accent); }
.chart .bar.dim { fill: var(--ink-3); }
.chart .target { stroke: var(--bone-dim); stroke-dasharray: 3 3; }
.empty { text-align: center; padding: 18px 8px; color: var(--bone-dim); font-size: 0.9rem; }
.entry-list { margin-top: 10px; font-size: 0.9rem; }
.entry-list div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.entry-list button { background: none; border: 0; color: var(--bone-dim); cursor: pointer; }

/* ---------- Figures ---------- */
.fig .floor { stroke: var(--line); stroke-width: 2; }
.fig .limb { stroke: var(--bone); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.fig .limb.far { stroke: var(--bone-dim); opacity: 0.55; }
.fig .head { fill: var(--bone); }
.fig .prop { fill: var(--accent); stroke: var(--accent); }
.fig .prop-line { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
.fig .bench { fill: var(--line); }
.fig .cable { stroke: var(--bone-dim); stroke-width: 1.5; stroke-dasharray: 3 3; }

