/* =====================================================================
   UNLOCK design system
   Bordeaux monochrome · Sora
   ===================================================================== */

@font-face { font-family: "Sora"; src: url("../fonts/sora.woff2") format("woff2"); font-weight: 100 800; font-display: swap; unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Sora"; src: url("../fonts/sora-ext.woff2") format("woff2"); font-weight: 100 800; font-display: swap; unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }

:root {
  --brand: #6D071A;
  --brand-deep: #4A0412;
  --brand-600: #8A1A2F;
  --brand-300: #C98A96;
  --brand-100: #F3DCE0;
  --brand-50:  #FBF1F3;

  --ink:    #18161B;
  --ink-2:  #45424B;
  --muted:  #7C7883;
  --line:   #E6E3E8;
  --line-2: #D6D2D9;
  --canvas: #F4F3F5;
  --surface:#FFFFFF;

  --ok: #2F7D4F;
  --danger: #B42318;

  --font-display: "Sora", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ui: "Sora", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;

  --fs-xs: .75rem;   /* 12 */
  --fs-sm: .8438rem; /* 13.5 */
  --fs-md: .9375rem; /* 15 */
  --fs-lg: 1.125rem; /* 18 */
  --fs-xl: 1.375rem; /* 22 */
  --fs-2xl: 1.75rem; /* 28 */
  --fs-3xl: 2.25rem; /* 36 */
  --fs-4xl: 3rem;    /* 48 */

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  --shadow-float: 0 1px 2px rgba(24, 22, 27, .06), 0 8px 24px -6px rgba(74, 4, 18, .18);
  --shadow-sheet: 0 -8px 40px -12px rgba(24, 22, 27, .28);

  --topbar-h: 60px;
  --bottomnav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);

  color-scheme: light;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font-family: var(--font-ui); font-size: var(--fs-md); line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button, a, select, input { touch-action: manipulation; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin: 0; }
p { margin: 0; }
.emoji { font-family: var(--emoji); font-style: normal; line-height: 1; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

/* Barres de défilement fines et discrètes (au lieu de la grosse barre grise par défaut) */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background-color: var(--line-2); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* =====================================================================
   App shell
   ===================================================================== */
.app {
  height: 100vh; height: 100dvh;
  display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}
.app--scroll { height: auto; min-height: 100dvh; overflow: visible; }

.topbar {
  position: relative; z-index: 1100;
  height: calc(var(--topbar-h) + var(--safe-t)); padding: var(--safe-t) 16px 0;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.app--scroll .topbar { position: sticky; top: 0; }

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex-shrink: 0; }
.brand__logo { width: 34px; height: 34px; border-radius: 9px; }
.brand__word { font-family: var(--font-display); font-weight: 800; font-size: 1.375rem; letter-spacing: -.04em; color: var(--brand); }

.nav {
  display: none; align-items: center; gap: 4px; margin-left: 24px; padding: 4px;
  border-radius: 999px; background: var(--canvas); border: 1px solid var(--line);
}
.nav__link {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 16px;
  border-radius: 999px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: var(--fs-sm);
  transition: background .15s, color .15s;
}
.nav__link:hover { background: rgba(255,255,255,.7); color: var(--ink); }
.nav__link[aria-current="page"] { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(24,22,27,.12); }
.nav__link + .nav__link { position: relative; }
.nav__link + .nav__link::before { content: ""; position: absolute; left: -3px; top: 25%; bottom: 25%; width: 1px; background: var(--line-2); }
.nav__link[aria-current="page"]::before, .nav__link[aria-current="page"] + .nav__link::before, .nav__link:hover::before, .nav__link:hover + .nav__link::before { opacity: 0; }
.nav__link .emoji { font-size: 1rem; }

.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

.bottomnav {
  position: relative; z-index: 1100;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  height: calc(var(--bottomnav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--line);
}
.bottomnav__link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: .6875rem; font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.bottomnav__link .emoji { font-size: 1.3rem; filter: grayscale(1); opacity: .65; transition: filter .2s, opacity .2s, transform .2s var(--ease); }
.bottomnav__link[aria-current="page"] { color: var(--brand); }
.bottomnav__link[aria-current="page"] .emoji { filter: none; opacity: 1; transform: translateY(-1px) scale(1.08); }

@media (max-height: 500px) and (max-width: 1023px) {
  :root { --topbar-h: 52px; --bottomnav-h: 50px; }
  .bottomnav__link { flex-direction: row; gap: 6px; font-size: .75rem; }
  .bottomnav__link .emoji { font-size: 1.1rem; }
  .brand__logo { width: 30px; height: 30px; }
}
@media (min-width: 1024px) {
  .nav { display: flex; }
  .bottomnav { display: none; }
  .topbar { padding-left: 24px; padding-right: 24px; }
}

/* =====================================================================
   Controls
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r-md);
  border: 1px solid transparent; background: var(--canvas); color: var(--ink);
  font-weight: 650; font-size: var(--fs-md); text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-600); }
.btn--outline { background: var(--surface); border-color: var(--line-2); }
.btn--outline:hover { border-color: var(--ink-2); }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--canvas); }
.btn--danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn--block { width: 100%; }
.btn .emoji { font-size: 1.05em; }

.iconbtn {
  width: 40px; height: 40px; flex-shrink: 0; display: inline-grid; place-items: center;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.iconbtn:hover { border-color: var(--line-2); background: var(--canvas); }
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn .emoji { font-size: 1.1rem; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--canvas);
  border: 1px solid var(--line);
}
.seg__btn {
  border: 0; background: transparent; height: 34px; padding: 0 14px; border-radius: 999px;
  font-weight: 650; font-size: var(--fs-sm); color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; transition: background .2s var(--ease), color .2s, box-shadow .2s;
}
.seg__btn[aria-pressed="true"] { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(24,22,27,.12); }
.seg--sm .seg__btn { height: 28px; padding: 0 10px; font-size: var(--fs-xs); }
.seg--block { display: flex; }
.seg--block .seg__btn { flex: 1; justify-content: center; }

.field { display: grid; gap: 6px; }
.field__label { font-size: var(--fs-sm); font-weight: 650; color: var(--ink-2); }
.select, .input {
  height: 44px; width: 100%; padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--line-2); background-color: var(--surface); color: var(--ink);
  font-weight: 550; font-size: 1rem; outline: none; transition: border-color .15s, box-shadow .15s;
}
.select {
  appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237C7883' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
.select:hover, .input:hover { border-color: var(--muted); }
.select:focus, .input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.select--pill { height: 40px; border-radius: 999px; font-size: var(--fs-sm); font-weight: 650; padding-left: 16px; width: auto; }

.search { position: relative; }
.search .emoji { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: .95rem; pointer-events: none; }
.search .input { padding-left: 38px; }
.search__clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--canvas); color: var(--muted); font-size: 18px; line-height: 1; display: grid; place-items: center; }
.search__clear:hover { color: var(--ink); background: var(--line); }
.search:has(.search__clear:not([hidden])) .input { padding-right: 42px; }

/* =====================================================================
   Loader: blocks unlocking along a route
   ===================================================================== */
.loader {
  position: fixed; inset: 0; z-index: 5000;
  display: grid; place-items: center; padding: 24px;
  background: var(--canvas);
  transition: opacity .35s var(--ease), visibility .35s;
}
.loader.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader__inner { display: grid; justify-items: center; gap: 28px; text-align: center; }
.loader__grid { display: grid; grid-template-columns: repeat(5, 22px); gap: 6px; }
.loader__cell { width: 22px; height: 22px; border-radius: 6px; background: var(--line); }
.loader__cell.is-route { animation: unlock 3.2s var(--ease) infinite; animation-delay: calc(var(--i) * 110ms); }
@keyframes unlock {
  0%   { background: var(--line); transform: scale(1); }
  8%   { background: var(--brand); transform: scale(.82); }
  14%  { background: var(--brand); transform: scale(1); }
  70%  { background: var(--brand); opacity: 1; }
  88%, 100% { background: var(--line); }
}
.loader__word { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-2xl); letter-spacing: -.04em; color: var(--brand); }
.loader__msg { min-height: 1.5em; color: var(--ink-2); font-weight: 550; font-size: var(--fs-md); transition: opacity .25s; }
.loader__msg.is-fading { opacity: 0; }
.loader__hint { color: var(--muted); font-size: var(--fs-sm); max-width: 34ch; margin: 10px auto 0; line-height: 1.5; transition: opacity .25s; }
.loader__hint.is-fading { opacity: 0; }
.loader__credit { position: absolute; bottom: calc(24px + var(--safe-b)); left: 0; right: 0; text-align: center; font-size: var(--fs-xs); color: var(--muted); }
.loader__credit a { color: var(--ink-2); font-weight: 600; text-decoration: none; }
.loader__credit a:hover { color: var(--brand); }

/* Calcul en cours (filtres, recalculs) : carte blanche discrète + voile flou optionnel */
.working {
  position: fixed; z-index: 1200; left: 0; right: 0; top: calc(var(--topbar-h) + var(--safe-t)); bottom: 0;
  display: grid; justify-items: center; align-items: start; padding: 16px; pointer-events: none;
  opacity: 0; transition: opacity .25s;
}
.working.is-on { opacity: 1; }
.working--veil { pointer-events: auto; align-items: center; background: rgba(244, 243, 245, .45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
@media (max-width: 1023px) { .working--veil { bottom: calc(var(--bottomnav-h) + var(--safe-b)); } }
.working__card {
  display: flex; align-items: center; gap: 14px; padding: 14px 20px 14px 16px; border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-float); border: 1px solid var(--line);
  transform: translateY(-6px); transition: transform .3s var(--ease); max-width: 100%;
}
.working.is-on .working__card { transform: none; }
.working__text { display: grid; gap: 2px; min-width: 0; }
.working__text b { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); letter-spacing: -.01em; }
.working__text span { font-size: var(--fs-xs); color: var(--muted); }
.working__text span:empty { display: none; }
.mini-grid { display: grid; grid-template-columns: repeat(3, var(--cell, 10px)); gap: 3px; flex-shrink: 0; }
.mini-grid i { width: var(--cell, 10px); height: var(--cell, 10px); border-radius: 3px; background: var(--line); animation: unlock 2.2s var(--ease) infinite; animation-delay: calc(var(--i) * 120ms); }

/* =====================================================================
   Sheets (bottom sheet on mobile, dialog on desktop)
   ===================================================================== */
.sheet { position: fixed; inset: 0; z-index: 3000; display: grid; align-items: end; visibility: hidden; }
.sheet.is-open { visibility: visible; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(24, 22, 27, .38); opacity: 0; transition: opacity .25s; }
.sheet.is-open .sheet__backdrop { opacity: 1; }
.sheet__panel {
  position: relative; width: 100%; max-height: min(88dvh, 720px); overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-sheet);
  padding: 8px 20px calc(24px + var(--safe-b));
  transform: translateY(100%); transition: transform .32s var(--ease);
}
.sheet.is-open .sheet__panel { transform: none; }
/* Fenêtres : pas de barre de défilement visible (on fait toujours défiler à la molette, au pavé ou au doigt).
   Un léger fondu en bas signale qu'il reste du contenu, et disparaît une fois en bas. */
.sheet__panel { scrollbar-width: none; }
.sheet__panel::-webkit-scrollbar { display: none; }
.sheet__panel::after {
  content: ""; position: sticky; bottom: calc(-24px - var(--safe-b)); display: block; height: 44px; margin-top: -44px;
  pointer-events: none; background: linear-gradient(rgba(255, 255, 255, 0), var(--surface) 80%);
  opacity: 0; transition: opacity .2s;
}
.sheet__panel.has-more::after { opacity: 1; }
.sheet__grip { width: 40px; height: 5px; border-radius: 99px; background: var(--line-2); margin: 4px auto 14px; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sheet__title { font-size: var(--fs-xl); overflow-wrap: break-word; }
.sheet__body { display: grid; gap: 14px; }
@media (min-width: 640px) {
  .sheet { align-items: center; justify-items: center; padding: 24px; }
  .sheet__panel { max-width: 440px; border-radius: var(--r-xl); padding: 24px; transform: translateY(16px) scale(.98); opacity: 0; transition: transform .28s var(--ease), opacity .2s; }
  .sheet.is-open .sheet__panel { transform: none; opacity: 1; }
  .sheet__grip { display: none; }
}

/* Carte identifiant Strava */
.idcard {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; margin-bottom: 14px; border-radius: var(--r-md);
  background: var(--brand-50); border: 1px solid var(--brand-100);
}
.idcard__text { display: grid; gap: 4px; min-width: 0; }
.idcard__label { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.idcard__num { font-family: var(--font-display); font-weight: 750; font-size: 1.5rem; letter-spacing: .02em; color: var(--brand-deep); user-select: all; overflow-wrap: anywhere; }
.idcard__copy { flex-shrink: 0; background: var(--surface); }
.idcard__copy.is-done { border-color: var(--ok); color: var(--ok); }

/* Menu : groupes de boutons clairement séparés */
.menu-group {
  list-style: none; margin: 0 0 12px; padding: 0; border-radius: var(--r-md);
  background: var(--canvas); border: 1px solid var(--line); overflow: hidden;
}
.menu-group li + li { border-top: 1px solid var(--line); }
.menu-item {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 60px; padding: 10px 14px;
  border: 0; background: transparent; text-align: left; text-decoration: none;
  font-weight: 650; color: var(--ink); transition: background .15s;
}
.menu-item:hover { background: var(--surface); }
.menu-item:focus-visible { outline-offset: -2px; }
.menu-item > span:not(.emoji) { flex: 1; min-width: 0; }
.menu-item .emoji { width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; background: var(--surface); font-size: 1.1rem; box-shadow: 0 1px 2px rgba(24,22,27,.06); }
.menu-item small { display: block; margin-top: 2px; font-weight: 500; color: var(--muted); font-size: var(--fs-xs); }
.menu-item__chev { width: 18px; height: 18px; flex-shrink: 0; color: var(--line-2); transition: transform .15s, color .15s; }
.menu-item:hover .menu-item__chev { color: var(--muted); transform: translateX(2px); }
.menu-item--danger { color: var(--danger); }
.menu-item--danger .emoji { background: #FDECEA; }
.menu-foot { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-xs); color: var(--muted); }
.menu-foot a { color: var(--muted); text-decoration: none; }
.menu-foot a:hover { color: var(--brand); text-decoration: underline; }

/* iOS install steps (a real sequence → numbered) */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; counter-increment: s; }
.steps li::before {
  content: counter(s); width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--brand-50); color: var(--brand); font-weight: 750; font-size: var(--fs-sm);
}
.steps svg { display: inline; width: 18px; height: 18px; vertical-align: -3px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottomnav-h) + var(--safe-b) + 16px); z-index: 4000;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; max-width: calc(100% - 32px);
  padding: 12px 16px; border-radius: var(--r-md); background: var(--ink); color: #fff; font-weight: 600; font-size: var(--fs-sm);
  box-shadow: var(--shadow-float); transition: opacity .2s, transform .3s var(--ease);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 1024px) { .toast { bottom: 24px; } }
/* Carte sur mobile : le panneau occupe le bas, le message s'affiche sous la barre des modes */
@media (min-width: 768px) { html:has(.mapview) .toast { left: calc(50% + 178px); max-width: calc(100% - 388px); } }
@media (min-width: 1024px) { html:has(.mapview) .toast { left: calc(50% + 188px); max-width: calc(100% - 408px); } }
@media (max-width: 767px) { html:has(.mapview) .toast { bottom: auto; top: calc(var(--topbar-h, 60px) + var(--safe-t, 0px) + 74px); transform: translate(-50%, -12px); } html:has(.mapview) .toast.is-on { transform: translate(-50%, 0); } }

/* =====================================================================
   Map page
   ===================================================================== */
.mapview { position: relative; min-height: 0; overflow: hidden; }
.mapview #map { position: absolute; inset: 0; background: #ECEBEE; }

.maptools {
  position: absolute; z-index: 900; top: 12px; left: 12px; right: 12px;
  display: flex; align-items: center; gap: 8px; pointer-events: none;
}
.maptools > * { pointer-events: auto; }
.maptools .seg { background: rgba(255,255,255,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: var(--shadow-float); border-color: transparent; }
.maptools .iconbtn, .maptools .select--pill { box-shadow: var(--shadow-float); border-color: transparent; }
.maptools__filters { display: none; gap: 8px; }
.maptools__spacer { flex: 1; }
.filter-dot { position: relative; }
.filter-dot.has-filter::after { content: ""; position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }

/* Panel: bottom sheet on phones, floating column from tablet up */
.panel {
  position: absolute; z-index: 950; left: 0; right: 0; bottom: 0;
  background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-sheet);
  display: flex; flex-direction: column; max-height: 62%;
  transition: transform .28s cubic-bezier(.2,.8,.2,1); will-change: transform;
}
.panel.is-dragging { transition: none; }
@media (max-width: 767px) {
  .panel.is-collapsed .panel__scroll { touch-action: none; overflow: hidden; }
  /* Le panneau passe au-dessus de la mention © OpenStreetMap (calque Leaflet à 1000) quand on le tire */
  .panel { z-index: 1001; }
  /* Prolongement blanc sous le panneau : quand on le tire vers le haut, la carte n'apparaît jamais
     entre le panneau et la barre du bas (coupé par .mapview, qui masque ce qui dépasse) */
  .panel::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 160px; background: var(--surface); pointer-events: none; }
}
/* Pages à écran fixe (carte) : la page elle-même ne doit jamais bouger ni rebondir */
html:has(.mapview), html:has(.mapview) body { height: 100%; overflow: hidden; overscroll-behavior: none; }
.panel__toggle {
  border: 0; background: transparent; width: 100%; padding: 10px 16px 4px; display: grid; justify-items: center;
  -webkit-tap-highlight-color: transparent; touch-action: none; cursor: grab;
}
.panel__toggle .sheet__grip { margin: 2px auto 6px; }
.panel__scroll { overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 16px; }
.panel.is-collapsed .panel__more { display: none; }

.stats { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 8px; }
.stat { padding: 12px; border-radius: var(--r-md); background: var(--canvas); min-width: 0; }
.stat__top { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.stat__val { display: block; margin-top: 4px; font-family: var(--font-display); font-weight: 750; font-size: var(--fs-xl); letter-spacing: -.03em; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat__val small { font-family: var(--font-ui); font-size: var(--fs-xs); font-weight: 650; color: var(--muted); letter-spacing: 0; margin-left: 2px; }
.stat__sub { display: block; margin-top: 6px; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.section { margin-top: 20px; }
.section__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section__title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }

.city { margin-top: 12px; padding: 16px; border-radius: var(--r-md); background: var(--brand-50); }
.city__name { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 750; letter-spacing: -.03em; color: var(--brand-deep); overflow-wrap: break-word; text-wrap: balance; }
.city__row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 10px; }
.city__pct { font-family: var(--font-display); font-size: var(--fs-3xl); font-weight: 800; letter-spacing: -.04em; color: var(--brand); line-height: 1; font-variant-numeric: tabular-nums; }
.city__meta { color: var(--ink-2); font-size: var(--fs-sm); text-align: right; }
.bar { height: 8px; border-radius: 99px; background: var(--brand-100); overflow: hidden; margin-top: 12px; }
.bar__fill { height: 100%; width: 0; border-radius: inherit; background: var(--brand); transition: width .6s var(--ease); }

.rank { list-style: none; margin: 0; padding: 0; }
.rank__item {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  width: 100%; padding: 10px 8px; border: 0; background: transparent; border-radius: var(--r-sm); text-align: left;
}
.rank__item:hover { background: var(--canvas); }
.rank__item[aria-current="true"] { background: var(--brand-50); }
.rank__pos { font-weight: 700; color: var(--muted); font-size: var(--fs-sm); text-align: center; font-variant-numeric: tabular-nums; }
.rank__name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank__val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--brand); font-size: var(--fs-sm); }
.rank__val small { display: block; font-weight: 500; color: var(--muted); font-size: var(--fs-xs); }

.legend { margin-top: 20px; }
.legend__scale { height: 8px; border-radius: 99px; background: linear-gradient(90deg, rgba(109,7,26,.2), rgba(109,7,26,1)); }
.legend__labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }

/* Blocs sans chemin (non comptés) : même hachure que sur la carte */
.hatch {
  display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px;
  background: repeating-linear-gradient(135deg, #A39CAB 0 1.3px, #EEECF0 1.3px 5px);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.legend__off { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.4; }
.legend__off .hatch { margin-top: 1px; }
.legend__off small { display: block; margin-top: 2px; color: var(--muted); }
.city__off { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; font-size: var(--fs-xs); line-height: 1.35; color: var(--ink-2); text-wrap: balance; }
.city__off[hidden] { display: none; }
.city__off .hatch { width: 12px; height: 12px; margin-top: 2px; }   /* aligné sur la 1re ligne si le texte passe à la ligne */

.calc-note {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start;
  margin-top: 14px; padding: 12px 12px 12px 14px; border-radius: var(--r-md);
  background: var(--brand-50); color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.45;
}
.calc-note p { margin: 0; }
.calc-note b { color: var(--brand-deep); }
.calc-note__x {
  width: 28px; height: 28px; margin: -4px -4px 0 0; border: 0; border-radius: 99px; background: transparent;
  color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.calc-note__x:hover { background: rgba(0,0,0,.05); color: var(--ink); }

.empty { padding: 18px 14px; border-radius: var(--r-md); border: 1px dashed var(--line-2); color: var(--ink-2); font-size: var(--fs-sm); text-align: center; }
.empty .emoji { display: block; font-size: 1.6rem; margin-bottom: 6px; }

.hint { margin-top: 16px; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); background: var(--canvas); font-size: var(--fs-sm); color: var(--ink-2); }
.hint button { border: 0; background: none; padding: 0; color: var(--brand); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

/* Phones: compact stat row */
@media (max-width: 767px) {
  .panel .stats { --cols: 3; }
  .panel .stat { padding: 10px; }
  .panel .stat__val { font-size: var(--fs-lg); }
  .panel .stat__sub { display: none; }
}
@media (max-width: 359px) {
  .panel .stats { gap: 6px; }
  .panel .stat { padding: 9px 8px; }
  .panel .stat__val { font-size: var(--fs-md); }
  .panel .stat__top { font-size: .6875rem; gap: 4px; }
}
/* Téléphones : crédits et zoom de la carte toujours au-dessus du panneau */
@media (max-width: 767px) { .mapview .leaflet-bottom { bottom: var(--panel-h, 120px); } }

/* Tablet + desktop: floating panel */
@media (min-width: 768px) {
  .maptools { left: calc(16px + var(--panel-w) + 12px); top: 16px; right: 16px; }
  .panel {
    --panel-w: 340px;
    top: 16px; left: 16px; bottom: auto; right: auto; width: var(--panel-w); max-height: calc(100% - 32px);
    border-radius: var(--r-lg); box-shadow: var(--shadow-float);
  }
  .mapview { --panel-w: 340px; }
  .panel__toggle { display: none; }
  .panel__scroll { padding: 18px; flex: 1; }
  .panel.is-collapsed .panel__more { display: block; }
  .panel .stats { --cols: 2; }
  .panel .stats .stat--wide { grid-column: 1 / -1; }
  .panel-heading { display: block !important; }
}
@media (min-width: 768px) and (max-height: 520px) { .panel { bottom: 12px; top: 12px; } }
@media (min-width: 1024px) { .mapview, .panel { --panel-w: 360px; } }
@media (min-width: 1440px) {
  .maptools__filters { display: flex; }
  .maptools__filterbtn { display: none; }
}
.panel-heading { display: none; margin-bottom: 14px; }
.panel-heading h1 { font-size: var(--fs-xl); }
.panel-heading p { color: var(--muted); font-size: var(--fs-sm); margin-top: 4px; }

/* Fenêtre « Soutenir Unlock » */
.support { display: grid; gap: 12px; color: var(--ink-2); font-size: var(--fs-md); line-height: 1.55; }
.support p { margin: 0; }
.support__costs { list-style: none; margin: 0; padding: 12px 14px; display: grid; gap: 10px; border-radius: var(--r-md); background: var(--canvas); }
.support__costs li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start; }
.support__costs b { color: var(--ink); font-weight: 650; }
.support__muted { font-size: var(--fs-sm); color: var(--muted); }
.support__cta { gap: 8px; }
.support__thanks { text-align: center; font-size: var(--fs-sm); color: var(--muted); font-style: italic; margin: 0; }
/* Bouton de don toujours visible en bas de la fenêtre ; le texte défile au-dessus */
.support__foot { position: sticky; bottom: calc(-24px - var(--safe-b)); z-index: 1; display: grid; gap: 10px;
  margin: 4px -20px calc(-24px - var(--safe-b)); padding: 12px 20px calc(16px + var(--safe-b)); background: var(--surface); }
.support__foot::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 28px; pointer-events: none;
  background: linear-gradient(rgba(255, 255, 255, 0), var(--surface)); }
.sheet__panel:has(.support__foot)::after { display: none; }
/* Ordinateur : les fenêtres s'affichent en entier, sans défilement (2 colonnes pour le menu et « Soutenir ») */
.menu-cols, .menu-col, .support__col { display: contents; }
@media (min-width: 640px) { .sheet__panel { max-height: calc(100dvh - 32px); } }
@media (min-width: 720px) {
  #sheet-menu .sheet__panel, #sheet-support .sheet__panel { max-width: min(780px, 100%); }
  .menu-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .menu-col { display: grid; gap: 12px; align-content: start; }
  .menu-col > * { margin-top: 0 !important; margin-bottom: 0 !important; }
  .support { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 28px; align-items: start; }
  .support__col { display: grid; gap: 12px; align-content: start; }
  .support__foot { position: static; margin: 4px 0 0; padding: 0; }
  .support__foot::before { display: none; }
}
@media (min-width: 640px) and (max-width: 719px) { .support__foot { margin-left: -24px; margin-right: -24px; padding-left: 24px; padding-right: 24px; } }

/* ---------- Carte : mode « Communes » (un département) ---------- */
.iconbtn--sm { width: 32px; height: 32px; }
.iconbtn--sm svg { width: 16px; height: 16px; }
.dep-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; min-width: 0; }
.dep-head__name { display: flex; align-items: baseline; gap: 6px; min-width: 0; font-family: var(--font-display); font-weight: 750; font-size: var(--fs-lg); letter-spacing: -.02em; }
.dep-head__name #dep-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dep-head__name .emoji { align-self: center; }
.dep-head__code { color: var(--muted); font-weight: 600; flex: none; }
.dep-change { position: relative; flex: none; overflow: hidden; }
.dep-change select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.dep-change:focus-within { box-shadow: 0 0 0 3px var(--brand-100); }
.dep-kpi { display: none; padding: 16px; border-radius: var(--r-md); background: var(--brand-50); }
.dep-kpi__lbl { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 650; color: var(--ink-2); }
.dep-kpi__val { display: block; margin-top: 6px; font-family: var(--font-display); font-weight: 800; font-size: var(--fs-3xl); letter-spacing: -.04em; line-height: 1.05; color: var(--brand); font-variant-numeric: tabular-nums; }
.dep-kpi__val small { font-size: var(--fs-lg); color: var(--brand-deep, #3B0410); opacity: .6; font-weight: 700; }
.dep-kpi__sub { display: block; margin-top: 4px; font-size: var(--fs-sm); color: var(--ink-2); }
.dep-kpi .bar { margin-top: 12px; }
.dep-kpi .bar__fill, .ctip .bar__fill, .ccard-m .bar__fill { display: block; transition: width .5s var(--ease); }
.dep-stats { --cols: 3; }
.dep-stats .dep-stats__d { display: none; }
.rank__sub { display: block; font-weight: 500; color: var(--muted); font-size: var(--fs-xs); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; }
.rank__val--big { font-size: var(--fs-md) !important; }
.dlegend { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.dlegend__zero { width: 28px; height: 10px; border-radius: 99px; border: 1px solid #D3CED7; background: #F8F7F9; flex: none; }
.dlegend__steps { display: flex; flex: 1; gap: 2px; }
.dlegend__steps i { flex: 1; height: 10px; background: rgba(109, 7, 26, var(--a)); }
.dlegend__steps i:first-child { border-radius: 99px 0 0 99px; }
.dlegend__steps i:last-child { border-radius: 0 99px 99px 0; }
.dlegend__lbl { display: grid; grid-template-columns: 36px 1fr auto; margin-top: 6px; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }

/* Fiche commune (mobile, dans le panneau) */
.ccard-m__nav { display: flex; align-items: center; justify-content: space-between; margin: -2px 0 6px; }
.ccard-m__back { border: 0; background: none; padding: 6px 0; font-weight: 650; font-size: var(--fs-sm); color: var(--ink-2); max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccard-m__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.ccard-m__id { min-width: 0; }
.ccard-m__name { font-family: var(--font-display); font-weight: 750; font-size: var(--fs-xl); letter-spacing: -.03em; color: var(--brand-deep, #3B0410); line-height: 1.15; overflow-wrap: anywhere; }
.ccard-m__sub { margin-top: 3px; font-size: var(--fs-xs); color: var(--muted); }
.ccard-m__pct { flex: none; font-family: var(--font-display); font-weight: 800; font-size: 2.4rem; letter-spacing: -.04em; line-height: .95; color: var(--brand); font-variant-numeric: tabular-nums; }
.ccard-m .bar { height: 8px; margin-top: 12px; }
.ccard-m__blocks { margin-top: 10px; font-size: var(--fs-sm); color: var(--ink-2); }
.ccard-m__blocks b { color: var(--ink); font-variant-numeric: tabular-nums; }
.ccard-m__stats { margin-top: 12px; --cols: 3; }

/* Infobulle (ordinateur / tablette) */
.ctip { position: absolute; z-index: 960; width: 248px; padding: 16px 16px 12px; background: var(--surface); border-radius: 18px;
  box-shadow: 0 18px 40px -12px rgba(24, 22, 27, .35), 0 2px 6px rgba(24, 22, 27, .08); animation: ctip-in .16s var(--ease); }
.ctip.is-off { visibility: hidden; }
@keyframes ctip-in { from { opacity: 0; transform: scale(.97); } }
@media (prefers-reduced-motion: reduce) { .ctip { animation: none; } }
.ctip__arrow { position: absolute; width: 14px; height: 14px; background: var(--surface); transform: rotate(45deg); }
.ctip[data-side="inside"] .ctip__arrow { display: none; }
.ctip__x { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--canvas); color: var(--muted); font-size: 18px; line-height: 1; display: grid; place-items: center; }
.ctip__x:hover { color: var(--ink); }
.ctip__name { font-family: var(--font-display); font-weight: 750; font-size: var(--fs-lg); letter-spacing: -.03em; color: var(--brand-deep, #3B0410); padding-right: 30px; line-height: 1.2; overflow-wrap: anywhere; }
.ctip__sub { margin-top: 3px; font-size: var(--fs-xs); color: var(--muted); line-height: 1.35; }
.ctip__row { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; }
.ctip__pct { font-family: var(--font-display); font-weight: 800; font-size: 2.25rem; letter-spacing: -.04em; line-height: 1; color: var(--brand); font-variant-numeric: tabular-nums; }
.ctip__lbl { color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; }
.ctip__bar { margin-top: 10px; height: 8px; }
.ctip__blocks { margin-top: 10px; font-size: var(--fs-sm); color: var(--ink-2); }
.ctip__blocks b { color: var(--ink); font-variant-numeric: tabular-nums; }
.ctip__meta { margin-top: 2px; font-size: var(--fs-xs); color: var(--muted); line-height: 1.35; }
.ctip__link { display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 12px; padding: 10px 0 2px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; font-size: var(--fs-sm); font-weight: 700; color: var(--brand); }
.ctip__link:hover { text-decoration: underline; text-underline-offset: 3px; }
.ctip__link[hidden] { display: none; }

@media (max-width: 767px) {
  /* 3 modes + bouton filtres sur une ligne : pas d'emoji dans les modes */
  .maptools .seg__btn .emoji { display: none; }
  .maptools .seg__btn { padding: 0 12px; }
  .ctip { display: none !important; }
}
@media (max-width: 359px) { .maptools .seg__btn { padding: 0 9px; font-size: var(--fs-sm); } }
@media (min-width: 768px) {
  .dep-kpi { display: block; }
  .dep-stats { --cols: 2 !important; margin-top: 8px; }
  .dep-stats .dep-stats__m { display: none; }
  .dep-stats .dep-stats__d { display: block; }
  .ccard-m { display: none !important; }
}

/* Leaflet polish */
.leaflet-container { font-family: var(--font-ui); }
/* Fond OpenStreetMap (sans clé) adouci pour rester sobre */
.map--osm .leaflet-tile-pane { filter: grayscale(1) contrast(.82) brightness(1.08); opacity: .9; }
.leaflet-control-zoom { border: 0 !important; box-shadow: var(--shadow-float) !important; border-radius: var(--r-md) !important; overflow: hidden; }
.leaflet-control-zoom a { width: 38px !important; height: 38px !important; line-height: 38px !important; color: var(--ink) !important; border-color: var(--line) !important; }
.leaflet-control-zoom a:hover { background: var(--brand-50) !important; color: var(--brand) !important; }
.leaflet-control-attribution { font-size: 10px !important; background: rgba(255,255,255,.75) !important; border-radius: 6px 0 0 0; padding: 0 6px !important; }
.leaflet-control-attribution a { color: var(--ink-2) !important; }
.leaflet-tooltip.cell-tip { border: 0; border-radius: var(--r-sm); padding: 8px 12px; box-shadow: var(--shadow-float); font-family: var(--font-ui); color: var(--ink); }
.leaflet-tooltip.cell-tip::before { display: none; }
.cell-tip b { font-family: var(--font-display); font-size: 1.05rem; color: var(--brand); }
.cell-tip span { display: block; font-size: var(--fs-xs); color: var(--muted); }
@media (hover: none) { .leaflet-control-zoom { display: none; } }

/* =====================================================================
   Content pages (stats, legal…)
   ===================================================================== */
.page { width: 100%; max-width: 1080px; margin: 0 auto; padding: 24px 16px calc(32px + var(--safe-b)); }
.page--narrow { max-width: 760px; }
.page__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page__title { font-size: clamp(1.85rem, 8.4vw, 2.25rem); letter-spacing: -.035em; line-height: 1.08; overflow-wrap: break-word; text-wrap: balance; }
.page__lead { color: var(--ink-2); margin-top: 8px; max-width: 60ch; }
@media (min-width: 768px) { .page { padding: 40px 24px 56px; } .page__title { font-size: var(--fs-4xl); } }

.scrollmain { overflow-y: auto; -webkit-overflow-scrolling: touch; }

.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; }
.filters .select { padding-left: 12px; padding-right: 30px; background-position: right 9px center; }
@media (min-width: 768px) { .filters { width: auto; gap: 10px; grid-template-columns: repeat(3, minmax(130px, 170px)); } }
/* Très petits écrans : 3 menus côte à côte ne tiennent pas sans couper le texte */
@media (max-width: 380px) { .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } .filters > .field:last-child { grid-column: 1 / -1; } }

.surface { background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--line); }
.kpis { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 560px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; } }
.kpi { padding: 16px; display: flex; flex-direction: column; min-width: 0; }
/* Cartes d'une même rangée : titres, chiffres, comparaisons et définitions alignés ligne à ligne */
@supports (grid-template-rows: subgrid) {
  .kpis { grid-auto-rows: auto; }
  .kpi { display: grid; grid-row: span 4; grid-template-rows: subgrid; row-gap: 0; align-content: start; }
  .kpi > .kpi__help { margin-top: 0; align-self: start; }
}
.nobr { white-space: nowrap; }
.kpi__val--text { font-size: clamp(1.15rem, 2.4vw, 1.6rem) !important; }
.kpi__sub { margin-top: 10px; font-size: var(--fs-sm); line-height: 1.35; }
.kpi__help { margin-top: auto; padding-top: 10px; font-size: var(--fs-xs); color: var(--muted); line-height: 1.35; }
.delta { font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.delta--up { color: var(--ok); }
.delta--down { color: var(--danger); }
.delta__ref { color: var(--muted); }
.period-note { margin: -6px 0 12px; font-size: var(--fs-sm); color: var(--muted); }
.kpi__label { display: flex; gap: 6px; align-items: flex-start; line-height: 1.3; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; }
.kpi__val { display: block; margin-top: 8px; font-family: var(--font-display); font-weight: 750; font-size: var(--fs-2xl); letter-spacing: -.035em; line-height: 1; font-variant-numeric: tabular-nums; }
@media (min-width: 768px) { .kpi { padding: 20px; } .kpi__val { font-size: var(--fs-3xl); } }

.chart { padding: 18px 16px 12px; margin-bottom: 14px; }
.chart__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 14px; }
.chart__title { font-size: var(--fs-lg); display: flex; gap: 8px; align-items: center; }
.chart__note { color: var(--muted); font-size: var(--fs-sm); }
.chart__box { position: relative; height: 240px; }
.chart__box--sm { height: 200px; }
/* ---------- Mes communes (Stats) ---------- */
.communes { margin-top: 28px; }
.ctable { padding: 14px; }
.ctable__tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 12px; }
.ctable__search { flex: 1 1 200px; min-width: 0; }
.ctable__search[hidden] { display: none; }
.ctable__sort { flex: 0 0 auto; min-width: 150px; }
.ctable__state { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 28px 12px; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; text-align: center; }
.ctable__state[hidden] { display: none; }
.ctable__state.is-empty .mini-grid { display: none; }
.ctable:not(.is-ready) .ctable__wrap, .ctable:not(.is-ready) .ccards, .ctable:not(.is-ready) .ctable__help { display: none; }
.ctable__foot { display: flex; justify-content: center; margin-top: 8px; }
.ctable__foot[hidden] { display: none; }
.ctable__help { margin-top: 12px; font-size: var(--fs-xs); color: var(--muted); line-height: 1.45; }
.ctable__none { padding: 18px 8px; text-align: center; color: var(--muted); font-size: var(--fs-sm); list-style: none; }

/* Mobile : cartes */
.ccards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ccard { padding: 12px 12px 11px; border-radius: var(--r-md); background: var(--canvas); min-width: 0; }
.ccard__top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: baseline; gap: 8px; }
.ccard__rank { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); min-width: 1.4em; font-variant-numeric: tabular-nums; }
.ccard__name { font-weight: 700; color: var(--ink); overflow-wrap: anywhere; line-height: 1.3; }
.ccard__pct { font-family: var(--font-display); font-weight: 750; color: var(--brand); font-variant-numeric: tabular-nums; }
.ccard .bar { margin-top: 8px; height: 6px; }
.ccard__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 9px; font-size: var(--fs-sm); color: var(--ink-2); }
.ccard__meta b { color: var(--ink); font-variant-numeric: tabular-nums; }
.ccard__dates { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; font-size: var(--fs-xs); color: var(--muted); }
.ccard .is-sorted, .ccard .is-sorted b { color: var(--brand); }
.ccard__meta .is-sorted b { font-weight: 800; }

/* Tablette / ordinateur : tableau */
.ctable__wrap { display: none; }
.ctable__table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; table-layout: fixed; }
.ctable__table th, .ctable__table td { padding: 10px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.ctable__table tbody tr:last-child > * { border-bottom: 0; }
.ctable__table tbody tr:hover > * { background: var(--canvas); }
.ctable__table thead th { padding-top: 4px; font-size: var(--fs-xs); color: var(--muted); font-weight: 650; }
.ctable__table thead th button { border: 0; background: none; padding: 4px 0; font: inherit; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.ctable__table thead th button:hover { color: var(--ink); }
.ctable__table thead th button::after { content: "↕"; opacity: .35; font-size: .9em; }
.ctable__table thead th[aria-sort="descending"] button, .ctable__table thead th[aria-sort="ascending"] button { color: var(--brand); }
.ctable__table thead th[aria-sort="descending"] button::after { content: "↓"; opacity: 1; }
.ctable__table thead th[aria-sort="ascending"] button::after { content: "↑"; opacity: 1; }
.ctable__table th:nth-child(2), .ctable__table td:nth-child(2) { text-align: left; }
.ctable__num { width: 34px; color: var(--muted); text-align: center !important; }
.ctable__name { font-weight: 650; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.ctable__table td small { color: var(--muted); }
.ctable__table td.is-sorted { color: var(--brand); font-weight: 700; }
.ctable__pct { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; width: 100%; }
.ctable__pct .bar { flex: 1; max-width: 70px; height: 6px; margin: 0; }
.ctable__pct .bar__fill { display: block; }
.ctable__pct b { min-width: 3.4em; text-align: right; }
.ctable__date { color: var(--ink-2); }
.ctable__table th:nth-child(3), .ctable__table th:nth-child(4) { width: 74px; }
.ctable__table th:nth-child(5) { width: 140px; }
.ctable__table th:nth-child(6) { width: 100px; }
.ctable__table th:nth-child(7), .ctable__table th:nth-child(8) { width: 88px; }

@media (min-width: 768px) {
  .ctable { padding: 16px 18px; }
  .ctable__wrap { display: block; }
  .ccards { display: none !important; }
  .ctable__sort { display: none; }
  .ctable__tools.no-search { display: none; }
  .ctable__search { flex: 0 1 300px; }
}
/* Tablette : on retire la 1re visite pour garder de l'air */
@media (min-width: 768px) and (max-width: 1023px) {
  .ctable__table th:nth-child(7), .ctable__table td:nth-child(7) { display: none; }
  .ctable__table th:nth-child(5) { width: 120px; }
  .ctable__pct .bar { max-width: 46px; }
}

.habits { margin-top: 28px; }
.habits__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 14px; }
.habits__title { font-size: var(--fs-xl); display: flex; align-items: center; gap: 10px; }
.kpis--3 { grid-template-columns: minmax(0, 1fr); }
/* 560-1023 px : 3 colonnes trop étroites -> la 1re carte sur toute la largeur, les 2 autres côte à côte */
@media (min-width: 560px) { .kpis--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis--3 > .kpi:first-child { grid-column: 1 / -1; } }
@media (min-width: 1024px) { .kpis--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpis--3 > .kpi:first-child { grid-column: auto; } }
.habits__charts { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .habits__charts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.habits__charts .chart { margin-bottom: 0; }
@media (min-width: 768px) { .chart { padding: 24px 24px 16px; } .chart__box { height: 300px; } }
.legend-inline { display: flex; gap: 14px; font-size: var(--fs-sm); color: var(--ink-2); }
.legend-inline i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Legal prose */
.prose { color: var(--ink-2); font-size: 1rem; line-height: 1.65; }
.prose h2 { color: var(--ink); font-size: var(--fs-xl); margin: 36px 0 10px; }
.prose h3 { color: var(--ink); font-size: var(--fs-lg); margin: 24px 0 8px; }
.prose p, .prose ul { margin: 0 0 12px; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: 6px; }
.prose a { color: var(--brand); font-weight: 600; text-underline-offset: 2px; }
.prose strong { color: var(--ink); }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); margin: 8px 0 16px; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; min-width: 140px; }
.prose th { color: var(--ink); font-weight: 700; }
.prose .meta { font-size: var(--fs-sm); color: var(--muted); }
@media (max-width: 640px) {
  .prose table, .prose tbody, .prose tr, .prose td { display: block; width: 100%; }
  .prose thead { display: none; }
  .prose tr { border: 1px solid var(--line); border-radius: var(--r-md); padding: 6px 4px; margin-bottom: 10px; background: var(--surface); }
  .prose td { border: 0; padding: 6px 12px; min-width: 0; }
  .prose td::before { content: attr(data-label); display: block; font-size: var(--fs-xs); font-weight: 700; color: var(--ink); }
}
.legal-nav { display: flex; gap: 8px; margin: 0 -16px 28px; padding: 0 16px 4px; overflow-x: auto; scrollbar-width: none; }
.legal-nav::-webkit-scrollbar { display: none; }
@media (min-width: 768px) { .legal-nav { margin: 0 0 28px; padding: 0; flex-wrap: wrap; } }
.legal-nav a { flex-shrink: 0; white-space: nowrap; text-decoration: none; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.legal-nav a[aria-current="page"] { background: var(--brand); border-color: var(--brand); color: #fff; }

.site-foot { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; padding: 20px 16px calc(20px + var(--safe-b)); font-size: var(--fs-xs); color: var(--muted); }
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--brand); text-decoration: underline; }

/* Strava attribution (official asset if provided, text otherwise) */
.powered { display: inline-flex; align-items: center; }
.powered img { height: 22px; width: auto; }
.powered--text { font-size: var(--fs-xs); font-weight: 650; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .loader__cell.is-route { animation: none; background: var(--brand); }
}

/* Onglets des pages légales : tiennent sur une ligne sur petit téléphone */
@media (max-width: 430px) { .legal-nav { gap: 6px; } .legal-nav a { padding: 7px 10px; font-size: var(--fs-xs); } }
@media (max-width: 380px) { .legal-nav .emoji { display: none; } }
@media (max-width: 340px) { .legal-nav { gap: 5px; } .legal-nav a { padding: 7px 8px; } }

/* Barres de défilement fines et discrètes (au lieu de la grosse barre grise du système) */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background-color: var(--line-2); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
::-webkit-scrollbar-corner { background: transparent; }

/* Stats : progression dans une commune */
.cprog__pick { min-width: 0; width: 220px; max-width: 100%; }
.cprog__pick .select { width: 100%; text-overflow: ellipsis; }
.cprog__kpi { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: -4px 0 12px; min-height: 30px; }
.cprog__kpi b { font-size: 26px; font-weight: 800; letter-spacing: -.02em; color: var(--brand); }
.cprog__kpi span:not(.delta) { color: var(--muted); font-size: var(--fs-sm); }
.cprog__state { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 16px;
  color: var(--muted); font-size: var(--fs-sm); background: rgba(255,255,255,.7); border-radius: 12px; }
.cprog__state.is-empty { background: transparent; }
@media (max-width: 560px) { .cprog__pick { width: 100%; } }
