/* Carnet 3D
 * Mise en page : colonne unique pensée pour le pouce (cartes d'exercice, barre d'onglets en bas),
 * élargie en grille sur grand écran.
 * Palette « terre de Sienne » : fond beige, accent terre de Sienne brûlée, olive, ocre et vert-de-gris.
 * Thème clair beige par défaut, thème sombre « expresso » si le système est en mode sombre.
 */
:root {
  --bg: #efe5d6;            /* beige lin */
  --surface: #faf5ec;       /* crème */
  --surface-2: #f2e9db;     /* sable clair */
  --line: #e0d2bf;          /* grège */
  --fg: #2e1f17;            /* brun expresso */
  --muted: #7a6455;         /* taupe */
  --accent: #b4532a;        /* terre de Sienne brûlée */
  --accent-ink: #fff8f0;
  --accent-soft: rgba(180, 83, 42, .12);
  --gold: #a5701a;          /* ocre : records */
  --gold-soft: rgba(196, 140, 40, .16);
  --good: #5d7537;          /* olive */
  --good-soft: rgba(93, 117, 55, .14);
  --warn: #a8611c;
  --bad: #9c2f26;           /* brique */
  --bad-soft: rgba(156, 47, 38, .10);
  --violet: #4c7570;        /* vert-de-gris : avant-bras, ajouts */
  --violet-soft: rgba(76, 117, 112, .13);
  --on-good: #fbf7ee;
  --on-gold: #fffaf0;
  --scrim: rgba(46, 31, 23, .45);
  --shadow: 0 10px 30px rgba(74, 44, 24, .14);
  --f-display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', system-ui, sans-serif;
  --f-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r: 14px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1410; --surface: #251b16; --surface-2: #30241d; --line: #43332a; --fg: #f1e6d6; --muted: #b39f8c;
    --accent: #e07a4f; --accent-ink: #1f120b; --accent-soft: rgba(224, 122, 79, .16);
    --gold: #e1b25a; --gold-soft: rgba(225, 178, 90, .15); --good: #a3b872; --good-soft: rgba(163, 184, 114, .15);
    --warn: #e0a05a; --bad: #e0705f; --bad-soft: rgba(224, 112, 95, .13); --violet: #8fb8b0; --violet-soft: rgba(143, 184, 176, .14);
    --on-good: #1b2410; --on-gold: #2a1c05; --scrim: rgba(10, 6, 4, .6);
    --shadow: 0 10px 30px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1410; --surface: #251b16; --surface-2: #30241d; --line: #43332a; --fg: #f1e6d6; --muted: #b39f8c;
  --accent: #e07a4f; --accent-ink: #1f120b; --accent-soft: rgba(224, 122, 79, .16);
  --gold: #e1b25a; --gold-soft: rgba(225, 178, 90, .15); --good: #a3b872; --good-soft: rgba(163, 184, 114, .15);
  --warn: #e0a05a; --bad: #e0705f; --bad-soft: rgba(224, 112, 95, .13); --violet: #8fb8b0; --violet-soft: rgba(143, 184, 176, .14);
  --on-good: #1b2410; --on-gold: #2a1c05; --scrim: rgba(10, 6, 4, .6);
  --shadow: 0 10px 30px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.5 var(--f-body);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 84px);
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
code { font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.tiny { font-size: 12.5px; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.eyebrow { margin: 0; font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.row-gap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-end { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; }
h1, h2, h3 { text-wrap: balance; }

/* ---------- Barre du haut ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 860px; margin: 0 auto; height: 54px; display: flex; align-items: center; justify-content: space-between; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--fg); font-family: var(--f-display); font-size: 22px; font-weight: 600; letter-spacing: .01em; }
.brand b { color: var(--accent); font-weight: 700; }
.brand-mark { width: 28px; height: 28px; }
.bm-a { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 34; stroke-linejoin: round; }
.bm-b { fill: none; stroke: var(--accent); stroke-width: 40; stroke-linecap: round; stroke-linejoin: round; }
.topbar-act { display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid transparent; background: transparent; display: grid; place-items: center; color: var(--fg); }
.icon-btn:hover { background: var(--surface-2); }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-right: 4px; }
.sync-dot[data-state="ok"] { background: var(--good); }
.sync-dot[data-state="err"] { background: var(--bad); }
.sync-dot[data-state="busy"] { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.demo-banner { max-width: 860px; margin: 10px auto 0; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; justify-content: space-between; font-size: 13px; color: var(--fg); background: var(--violet-soft); border: 1px solid color-mix(in srgb, var(--violet) 40%, transparent); border-radius: 12px; padding: 8px 12px; margin-left: max(16px, env(safe-area-inset-left, 0px)); margin-right: max(16px, env(safe-area-inset-right, 0px)); }
@media (min-width: 892px) { .demo-banner { margin-left: auto; margin-right: auto; } }
.btn-link { background: none; border: 0; padding: 4px 0; color: var(--violet); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.view { max-width: 860px; margin: 0 auto; padding-block: 14px 0; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 14px; outline: none; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); font-weight: 600; font-size: 14px; }
.btn:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-lg { min-height: 52px; font-size: 16px; width: 100%; border-radius: 14px; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: var(--accent-ink); }
.btn-danger-ghost { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: var(--bad-soft); }
.btn-ghost { display: inline-flex; align-items: center; gap: 5px; background: none; border: 0; color: var(--muted); font-size: 13px; font-weight: 600; padding: 8px 6px; border-radius: 8px; }
.btn-ghost:hover:not(:disabled) { color: var(--fg); background: var(--surface-2); }
.btn-ghost:disabled { opacity: .4; }
.btn-ghost .ic { width: 15px; height: 15px; }
.btn-ghost.danger { color: var(--bad); }

/* ---------- Séance : choix ---------- */
.sess-chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.sess-chip { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; text-align: left; padding: 9px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); }
.sess-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.sc-key { font-family: var(--f-display); font-weight: 700; font-size: 20px; line-height: 1; }
.sess-chip[aria-pressed="true"] .sc-key { color: var(--accent); }
.sc-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sc-day { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sc-day b { color: var(--good); font-weight: 600; }

.sess-head { padding: 4px 2px 2px; display: flex; flex-direction: column; gap: 8px; }
.sh-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sh-title { margin: 2px 0 0; font-family: var(--f-display); font-weight: 700; font-size: 34px; line-height: 1.02; letter-spacing: .005em; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sh-key { font-family: var(--f-display); color: var(--accent); font-weight: 700; }
.sh-focus { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.sh-clock { font-family: var(--f-display); font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .35s ease; }
.sh-count { margin: 0; font-size: 13px; color: var(--muted); }
.sh-count b { color: var(--fg); font-variant-numeric: tabular-nums; }

/* ---------- Blocs & cartes ---------- */
.block { display: flex; flex-direction: column; gap: 8px; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 6px 2px 0; }
.bh-label { font-family: var(--f-display); font-size: 17px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.bh-hint { font-size: 12px; color: var(--muted); text-align: right; }
.block-fore .bh-label { color: var(--violet); }

.ex-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.ex-card.is-complete { background: color-mix(in srgb, var(--surface) 70%, var(--bg)); }
.ex-head { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: none; border: 0; text-align: left; color: var(--fg); }
.ex-code { flex: none; font-family: var(--f-display); font-weight: 700; font-size: 15px; letter-spacing: .02em; min-width: 34px; height: 28px; display: inline-grid; place-items: center; padding: 0 6px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.block-fore .ex-code { background: var(--violet-soft); color: var(--violet); }
.ex-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ex-name { font-weight: 650; font-size: 15px; line-height: 1.3; }
.ex-target { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ex-count { flex: none; font-family: var(--f-display); font-size: 17px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 32px; text-align: right; }
.ex-count.ok { color: var(--good); display: grid; place-items: center; width: 30px; height: 30px; min-width: 0; border-radius: 50%; background: var(--good-soft); }
.ex-body { padding: 0 14px 10px; display: flex; flex-direction: column; gap: 10px; }
.ex-meta { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.ex-meta .last { color: var(--fg); }
.ex-meta .last .lbl { color: var(--muted); margin-right: 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.ex-meta .last em { color: var(--muted); font-style: normal; }
.goal { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 4px 10px 4px 8px; border-radius: 99px; }
.goal .ic { width: 14px; height: 14px; }
.goal-up { background: var(--good-soft); color: var(--good); }
.goal-hold { background: var(--accent-soft); color: var(--accent); }
.goal-new { background: var(--surface-2); color: var(--muted); }
.goal-max { background: var(--gold-soft); color: var(--gold); }
.goal-down { background: var(--bad-soft); color: var(--bad); }
.goal-live { border: 1px solid currentColor; }
.rules { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 9px; font-size: 14px; }
.rules li { max-width: 70ch; }
.rules a { text-decoration: none; font-weight: 600; font-size: 12px; }

.sets { display: flex; flex-direction: column; gap: 6px; }
.set-row { position: relative; display: grid; grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr) 48px; gap: 8px; align-items: center; }
.sets-bw .set-row { grid-template-columns: 26px minmax(0, 1fr) 48px; }
.set-head { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.set-head span:first-child { text-align: center; }
.set-n { text-align: center; font-family: var(--f-display); font-size: 18px; font-weight: 600; color: var(--muted); }
.field { position: relative; display: block; min-width: 0; }
.field input { width: 100%; height: 46px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 44px 0 12px; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--fg); -moz-appearance: textfield; }
.field input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); font-weight: 500; }
.field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field i { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 12px; color: var(--muted); pointer-events: none; }
.field-pdc { height: 46px; display: flex; align-items: center; padding: 0 12px; border-radius: 11px; border: 1px dashed var(--line); color: var(--muted); font-size: 13px; }
.check { width: 48px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); display: grid; place-items: center; transition: transform .12s ease, background .15s ease; }
.check .ic { width: 22px; height: 22px; stroke-width: 2.5; }
.check:active { transform: scale(.93); }
.set-row.done .check { background: var(--good); border-color: var(--good); color: var(--on-good); }
.set-row.done .field input { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); background: var(--good-soft); }
.pr-tag { position: absolute; right: 56px; top: -7px; display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: var(--gold); color: var(--on-gold); border-radius: 99px; padding: 1px 7px 1px 5px; }
.pr-tag .ic { width: 11px; height: 11px; }
.ex-foot { display: flex; gap: 2px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 4px; margin: 0 -6px; }
.ex-info { font-size: 13.5px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.ex-info p { margin: 0 0 6px; }
.ex-info p:last-child { margin: 0; }

.status { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border-radius: 6px; padding: 2px 7px; vertical-align: 1px; }
.st-keep { background: var(--good-soft); color: var(--good); }
.st-adjust { background: var(--accent-soft); color: var(--accent); }
.st-replace { background: var(--gold-soft); color: var(--gold); }
.st-new { background: var(--violet-soft); color: var(--violet); }

.finish-wrap { display: flex; flex-direction: column; gap: 8px; align-items: center; padding: 8px 0 4px; text-align: center; }

/* ---------- Chrono ---------- */
.timer { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); z-index: 25; padding: 0 max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px)); pointer-events: none; }
.timer-in { pointer-events: auto; max-width: 520px; margin: 0 auto; display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 18px; padding: 8px 10px 8px 8px; box-shadow: var(--shadow); }
.t-ring { width: 44px; height: 44px; transform: rotate(-90deg); flex: none; }
.t-track { fill: none; stroke: var(--surface-2); stroke-width: 5; }
.t-prog { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 113.1; stroke-dashoffset: 0; transition: stroke-dashoffset .25s linear; }
.t-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.t-txt b { font-family: var(--f-display); font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.t-txt span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-btns { display: flex; gap: 6px; }
.t-btn { min-width: 44px; height: 40px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 650; font-size: 14px; color: var(--fg); display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.timer.is-over .timer-in { border-color: var(--good); }
.timer.is-over .t-prog { stroke: var(--good); }
.timer.is-over .t-txt span { color: var(--good); font-weight: 600; }

/* ---------- Navigation ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 26; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.nav-in { max-width: 560px; margin: 0 auto; height: var(--nav-h); display: grid; grid-template-columns: repeat(4, 1fr); }
.nav-btn { background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.nav-btn .ic { width: 22px; height: 22px; }
.nav-btn[aria-current="page"] { color: var(--accent); }
.nav-btn[aria-current="page"] .ic { stroke-width: 2.4; }

/* ---------- Pages ---------- */
.page-head h1 { margin: 2px 0 0; font-family: var(--f-display); font-size: 36px; font-weight: 700; line-height: 1.05; }
.lead { margin: 8px 0 0; color: var(--muted); max-width: 64ch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; }
.card-head h2 { margin: 0; font-family: var(--f-display); font-size: 22px; font-weight: 600; letter-spacing: .01em; display: flex; align-items: baseline; gap: 8px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.t-lbl { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.t-val { font-family: var(--f-display); font-size: 34px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.t-sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.t-sub .ic { width: 13px; height: 13px; color: var(--gold); }
.t-sub.good { color: var(--good); }
.tiles-4 .tile { flex-direction: row; align-items: center; gap: 10px; }
.tiles-4 .t-val { font-size: 30px; }

.select { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 12px; font-size: 15.5px; font-weight: 600; color: var(--fg); }
.seg { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; overflow-x: auto; }
.seg button { flex: 1 0 auto; border: 0; background: none; border-radius: 9px; padding: 8px 10px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(74, 44, 24, .18); }
.evo-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.evo-stats div { display: flex; flex-direction: column; min-width: 0; }
.evo-stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.evo-stats b { font-family: var(--f-display); font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.evo-stats em { font-style: normal; font-size: 12px; color: var(--muted); }
.evo-stats .pos b { color: var(--good); }

/* ---------- Graphiques ---------- */
.chart-box { position: relative; width: 100%; min-width: 0; }
.chart { display: block; overflow: visible; }
.chart-grid line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart-tick { fill: var(--muted); font-size: 11px; font-family: var(--f-body); font-variant-numeric: tabular-nums; }
.chart-line { stroke: var(--accent); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart-grad-top { stop-color: var(--accent); stop-opacity: .28; }
.chart-grad-bottom { stop-color: var(--accent); stop-opacity: 0; }
.chart-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart-dot.is-pr { fill: var(--gold); stroke: var(--surface); stroke-width: 2; }
.chart-dot.is-last { fill: var(--accent); stroke: var(--surface); stroke-width: 2.5; }
.chart-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-focus { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart-tip { position: absolute; transform: translate(-50%, -100%); background: var(--fg); color: var(--bg); border-radius: 10px; padding: 6px 10px; font-size: 12px; line-height: 1.35; pointer-events: none; display: flex; flex-direction: column; white-space: nowrap; box-shadow: var(--shadow); z-index: 2; }
.chart-tip strong { font-family: var(--f-display); font-size: 18px; font-weight: 700; }
.chart-tip small { opacity: .75; }
.zone { fill: var(--good-soft); }
.zone-label { fill: var(--good); }
.bar-ok { fill: var(--accent); }
.bar-low { fill: color-mix(in srgb, var(--accent) 45%, var(--surface-2)); }
.bar-label { fill: var(--fg); font-size: 12.5px; font-family: var(--f-body); }
.bar-value { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; font-family: var(--f-body); }
.heat-box { overflow-x: auto; }
.heat-cell { fill: var(--surface-2); }
.heat-cell.on { fill: var(--accent); }
.heat-txt { fill: var(--accent-ink); font-size: 9.5px; font-weight: 700; font-family: var(--f-body); pointer-events: none; }
.spark-line { stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; }
.spark-area { fill: var(--accent-soft); }
.spark-dot { fill: var(--accent); }
.spark-flat { stroke: var(--line); stroke-width: 2; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.tbl td:first-child { white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }

.pr-rows { list-style: none; margin: 0 -6px; padding: 0; display: flex; flex-direction: column; }
.pr-row { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 96px 64px 64px; gap: 10px; align-items: center; padding: 9px 6px; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; color: var(--fg); border-radius: 8px; }
.pr-rows li:last-child .pr-row { border-bottom: 0; }
.pr-row:hover { background: var(--surface-2); }
.pr-name { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; }
.pr-name b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-name .muted { font-size: 12px; }
.pr-best { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.pr-best b { font-family: var(--f-display); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pr-best .muted { font-size: 11px; }
.delta { justify-self: end; white-space: nowrap; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; padding: 3px 7px; border-radius: 8px; }
.delta.pos { background: var(--good-soft); color: var(--good); }
.delta.zero { background: var(--surface-2); color: var(--muted); }
@media (max-width: 420px) { .pr-row { grid-template-columns: minmax(0, 1fr) 64px 60px; } .pr-spark { display: none; } }

.bw-form { display: flex; gap: 8px; align-items: center; }
.bw-form input { flex: 1; min-width: 0; height: 44px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 12px; font-size: 17px; font-weight: 600; }

/* ---------- Vides ---------- */
.empty { text-align: center; padding: 40px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty h1 { margin: 6px 0 0; font-family: var(--f-display); font-size: 30px; }
.empty p { margin: 0; color: var(--muted); max-width: 46ch; }
.empty-art { width: 64px; height: 64px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.empty-art .ic { width: 30px; height: 30px; }

/* ---------- Historique ---------- */
.month { margin: 6px 2px -4px; font-family: var(--f-display); font-size: 18px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.hist-head { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: none; border: 0; text-align: left; color: var(--fg); }
.hist-key { font-family: var(--f-display); font-weight: 700; font-size: 20px; color: var(--accent); width: 34px; flex: none; }
.hist-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hist-main .muted { font-size: 12.5px; }
.hist-main .muted::first-letter { text-transform: uppercase; }
.hist-nums { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chev { transition: transform .2s; color: var(--muted); }
.hist.is-open .chev { transform: rotate(180deg); }
.hist-body { padding: 0 14px 12px; }
.hist-note { margin: 0 0 8px; font-size: 13.5px; background: var(--surface-2); padding: 8px 10px; border-radius: 10px; }
.warn { color: var(--warn); font-size: 13px; margin: 0; }

/* ---------- Programme ---------- */
.prog-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.prog-list li { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.prog-list li:first-child { padding-top: 0; }
.prog-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.prog-list p { margin: 0; font-size: 13.5px; max-width: 70ch; }
.pl-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pl-top b { font-weight: 650; }
.pl-dose { color: var(--muted); font-size: 12.5px !important; font-variant-numeric: tabular-nums; }
.was { color: var(--muted); font-size: 12.5px !important; }
.refs a { font-size: 12px; text-decoration: none; font-weight: 600; }
.method { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.method li { max-width: 70ch; }
.ref-list { margin: 0; padding-left: 26px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.ref-list li { border-radius: 6px; transition: background .4s; }
.ref-list li.flash { background: var(--accent-soft); color: var(--fg); }

/* ---------- Modale ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom, 0px)); }
@media (min-width: 640px) { .modal { align-items: center; } }
.modal-card { position: relative; width: 100%; max-width: 520px; max-height: calc(100% - 20px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 20px 18px 18px; box-shadow: var(--shadow); animation: up .22s ease; }
@keyframes up { from { transform: translateY(16px); opacity: .6; } }
.modal-x { position: absolute; right: 8px; top: 8px; }
.modal-card h2 { margin: 0 40px 14px 0; font-family: var(--f-display); font-size: 26px; font-weight: 700; line-height: 1.1; }
.modal-card h3 { margin: 18px 0 6px; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.modal-card input[type="date"], .modal-card textarea, .modal-card input[type="password"] { width: 100%; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-2); padding: 10px 12px; font-size: 16px; }
.modal-card .row-gap input[type="password"] { flex: 1; min-width: 160px; width: auto; }
.lbl-block { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; text-transform: uppercase; letter-spacing: .05em; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
.sum-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sum-grid div { background: var(--surface-2); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; }
.sum-grid b { font-family: var(--f-display); font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.sum-grid span { font-size: 12px; color: var(--muted); }
.pr-list { margin-top: 12px; background: var(--gold-soft); border-radius: 12px; padding: 10px 12px; }
.pr-list .eyebrow { color: var(--gold); }
.pr-list .ic { width: 14px; height: 14px; }
.pr-list ul { margin: 6px 0 0; padding-left: 18px; font-size: 13.5px; }
.modal-card .warn { margin-top: 10px; }
.set-grid { display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; align-items: center; font-size: 14px; }
.inp-u { display: flex; align-items: center; gap: 6px; }
.inp-u input { width: 90px; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); text-align: right; padding: 0 10px; font-size: 16px; font-weight: 600; }
.inp-u span { color: var(--muted); font-size: 13px; width: 18px; }
.set-grid input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.confirm-box { margin-top: 10px; background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; }
.confirm-box p { margin: 0 0 8px; }

.toast { position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 60; background: var(--fg); color: var(--bg); font-weight: 600; font-size: 13.5px; padding: 10px 16px; border-radius: 99px; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center; }

/* ---------- Grand écran ---------- */
@media (min-width: 980px) {
  .view, .topbar-in { max-width: 1040px; }
  .demo-banner { max-width: 1008px; }
  .sess-chips { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .block { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: start; }
  .block-head { grid-column: 1 / -1; }
  .block-fore { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .finish-wrap { max-width: 420px; margin: 0 auto; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
