:root {
  /* ---- Mode clair — palette premium neutre + indigo ---- */
  --bg: #f7f7fa;
  --surface: #ffffff;
  --surface-2: #f3f3f7;
  --ink: #1a1a24;
  --ink-soft: #5c5c6b;
  --muted: #9c9caa;
  --line: #ebebf0;
  --brand: #5b5bf0;
  --brand-ink: #4a45d6;
  --brand-soft: #eeeefd;
  --accent: #5b5bf0;
  --good: #10a675;
  --good-soft: #e7f6f0;
  --bad: #e5484d;
  --bad-soft: #fdecec;
  --hero-1: #23232e;
  --hero-2: #16161d;
  --shadow: 0 1px 2px rgba(24, 24, 40, .04), 0 6px 20px rgba(24, 24, 40, .05);
  --radius: 16px;
  --mix: #ffffff;
  --sidebar-bg: #ffffff;
  --sidebar-ink: #1a1a24;
  color-scheme: light;
}

/* ---------- Mode sombre — palette premium profonde ---------- */
html[data-theme="dark"] {
  --bg: #09090c;
  --surface: #141419;
  --surface-2: #1c1c23;
  --ink: #f3f3f6;
  --ink-soft: #a7a7b6;
  --muted: #6a6a78;
  --line: #26262e;
  --brand: #7b7bf7;
  --brand-ink: #adadfb;
  --brand-soft: #1e1e2e;
  --accent: #7b7bf7;
  --good: #2bd08a;
  --good-soft: #0f2a20;
  --bad: #f2555a;
  --bad-soft: #2e1719;
  --hero-1: #20202a;
  --hero-2: #131318;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .5);
  --mix: #141419;
  --sidebar-bg: #0c0c10;
  --sidebar-ink: #e7e7ec;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--surface-2);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
/* Rebond élastique iOS : la zone révélée au-delà des bords est peinte avec le fond de <html>.
   On lui donne la couleur de la barre du haut pour que tirer vers le bas prolonge la barre
   au lieu d'ouvrir une « coupure » d'une autre couleur. <body> garde le fond de la page. */
html { background: var(--sidebar-bg); }
body { background: var(--surface-2); min-height: 100vh; }
/* Prolongements hors écran, révélés pendant le rebond : ils suivent la page quand iOS
   la fait rebondir, donc la zone découverte garde la couleur de l'app (barre en haut,
   fond de page en bas) au lieu d'ouvrir une coupure. Larges en X pour couvrir les
   rebonds en diagonale. Invisibles à l'écran en temps normal. */
body::before, body::after {
  content: ""; position: fixed; left: -30vw; right: -30vw; height: 70vh;
  z-index: -1; pointer-events: none;
}
body::before { top: -70vh; background: var(--sidebar-bg); }
body::after { bottom: -70vh; background: var(--surface-2); }

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .68rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: .25rem;
}
.eyebrow svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 5px; stroke-width: 2.2; }
.ic { width: 1.05em; height: 1.05em; vertical-align: -.15em; margin-right: 4px; flex: none; }
.muted { color: var(--ink-soft); font-size: .9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  color: var(--sidebar-ink);
  padding: 1.5rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.brand { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.brand-mark {
  display: grid; place-items: center;
  color: var(--ink);
  transition: color .2s;
}
.brand-mark svg { width: 32px; height: 32px; }
.brand strong { display: block; font-size: 1.1rem; color: var(--ink); letter-spacing: -.02em; }
.brand span { font-size: .75rem; color: var(--muted); }

nav { display: flex; flex-direction: column; gap: .15rem; }
.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .75rem;
  border: none; background: transparent;
  color: var(--ink-soft);
  border-radius: 10px;
  font-size: .9rem; font-weight: 550;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; }
.nav-item.active .nav-ico { color: var(--brand); }
.nav-ico { width: 19px; height: 19px; flex: none; opacity: .9; }

.sidebar-footer { margin-top: auto; font-size: .8rem; color: var(--muted); }
.sidebar-footer p { text-transform: uppercase; letter-spacing: .07em; font-size: .65rem; font-weight: 700; margin-bottom: .5rem; }
.sidebar-footer strong { display: block; margin-top: .5rem; color: var(--ink); font-size: .85rem; }
.progress-track { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--brand); transition: width .4s ease; }

/* ---------- Main ---------- */
main { padding: 1.6rem 2rem 4rem; max-width: 1180px; width: 100%; min-width: 0; }
/* Les onglets avec gros tableaux profitent de toute la largeur de l'écran */
main:has(#kpi.active), main:has(#habits.active) { max-width: 1600px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem;
}
.topbar h1 { font-size: 1.7rem; }
.topbar-xp { display: flex; align-items: center; gap: .65rem; }
.xp-rank {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: .3rem .6rem; border-radius: 99px; background: var(--brand-soft); color: var(--brand-ink);
}
.xp-mini-track { width: 90px; height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; }
.xp-mini-track span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .4s; }
.topbar-xp strong { font-size: .82rem; color: var(--ink-soft); }
.theme-toggle {
  flex: none; width: 34px; height: 34px; border-radius: 9px;
  border: none; background: transparent; color: var(--ink-soft);
  display: grid; place-items: center; transition: background .15s, color .15s;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--ink); }
.theme-toggle svg { width: 19px; height: 19px; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html:not([data-theme="dark"]) .theme-toggle .icon-sun { display: none; }

/* Bande permanente des quêtes du jour (sous la topbar, toutes rubriques) */
.quest-bar {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  padding: .5rem .85rem; margin-bottom: 1.4rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.quest-bar:empty { display: none; }
.quest-bar[hidden] { display: none; }
.qbar-label {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); display: inline-flex; align-items: center; gap: .4rem; flex: none;
}
.qbar-count { color: var(--brand-ink); background: var(--brand-soft); border-radius: 99px; padding: .05rem .45rem; font-size: .68rem; }
.qbar-chips { display: flex; gap: .5rem; flex-wrap: wrap; flex: 1; min-width: 0; }
.qbar-chip {
  display: inline-flex; align-items: center; gap: .45rem; max-width: 100%;
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 99px;
  padding: .28rem .75rem .28rem .35rem; font-size: .82rem; font-weight: 600; color: var(--ink);
  transition: border-color .15s;
}
.qbar-chip:hover { border-color: var(--brand); }
.qbar-check {
  width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--muted);
  display: grid; place-items: center; font-size: .68rem; color: #fff; flex: none;
}
.qbar-chip.done .qbar-check { background: var(--good); border-color: var(--good); }
.qbar-chip.done .qbar-text { text-decoration: line-through; color: var(--ink-soft); }
.qbar-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qbar-empty { font-size: .82rem; color: var(--ink-soft); }
.qbar-plan { border: none; background: none; color: var(--brand-ink); font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; font-size: inherit; }

.view { display: none; flex-direction: column; gap: 1.2rem; }
.view.active { display: flex; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-head-actions { display: flex; align-items: center; gap: .6rem; }
.panel-heading h2 { font-size: 1.15rem; }

/* ---------- Buttons ---------- */
.button {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: .6rem 1rem;
  font-size: .88rem; font-weight: 600;
  transition: transform .08s, background .15s, box-shadow .15s;
}
.button:active { transform: translateY(1px); }
.button svg { width: 15px; height: 15px; vertical-align: -3px; margin-right: 6px; stroke-width: 2.2; }
.button.primary { background: var(--brand); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 32%, transparent); }
.button.primary:hover { background: var(--brand-ink); box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 40%, transparent); }
.button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.button.secondary:hover { background: var(--surface-2); }
.button.light { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.25); }
.button.light:hover { background: rgba(255,255,255,.28); }
.button.danger { background: var(--bad-soft); color: var(--bad); }
.button.danger:hover { background: color-mix(in srgb, var(--bad) 18%, var(--mix)); }
.button.day-reset { background: transparent; color: rgba(255,255,255,.8); border-color: rgba(255,255,255,.25); }

/* ---------- Day hero ---------- */
.day-hero {
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2));
  color: #fff; border: none;
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
}
.day-hero .eyebrow { color: rgba(255,255,255,.75); }
.day-hero h2 { font-size: 1.5rem; }
.day-hero-summary { margin-top: .5rem; color: rgba(255,255,255,.88); max-width: 460px; line-height: 1.5; }
.day-focus { text-align: center; }
.day-timer { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.day-timer.done { animation: timerdone 1s ease-in-out infinite; }
@keyframes timerdone { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.focus-set { display: inline-flex; align-items: center; gap: .4rem; margin-top: .55rem; }
.focus-step {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.08);
  color: #fff; font-weight: 800; font-size: 1.1rem; line-height: 1; display: grid; place-items: center;
  transition: background .15s;
}
.focus-step:hover { background: rgba(255,255,255,.2); }
.focus-min {
  width: 54px; text-align: center; font-weight: 800; font-size: .95rem; padding: .3rem .2rem;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.22); color: #fff; border-radius: 8px;
}
.focus-min::-webkit-inner-spin-button, .focus-min::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.focus-unit { color: rgba(255,255,255,.75); font-size: .8rem; font-weight: 600; }
.focus-set.is-disabled { opacity: .45; pointer-events: none; }
.day-focus-actions { display: flex; gap: .5rem; margin-top: .6rem; }

/* ---------- Activity counters ---------- */
.activity-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem; }
.activity-cell {
  border: 1px solid var(--line); border-radius: 14px; padding: 1rem; text-align: center;
  background: var(--surface-2);
}
.activity-cell.rdv { background: var(--brand-soft); border-color: #d7dcf6; }
.activity-cell .ac-label { font-size: .78rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.activity-cell .ac-count { display: block; font-size: 2rem; font-weight: 800; margin: .3rem 0; font-variant-numeric: tabular-nums; }
.activity-actions { display: flex; gap: .4rem; justify-content: center; }
.activity-actions button {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); font-size: 1.1rem; font-weight: 700; color: var(--ink);
  display: grid; place-items: center;
}
.activity-actions button.plus { background: var(--brand); color: #fff; border-color: var(--brand); }
.activity-actions button:hover { filter: brightness(.97); }

/* ---------- Relance radar ---------- */
.radar {
  border-radius: var(--radius); padding: 1.1rem 1.3rem;
  border: 1px solid #fed7aa; background: #fff7ed;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.radar.clear { border-color: var(--good-soft); background: #f0fdf4; }
.radar h3 { font-size: 1rem; }
.radar .radar-chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .5rem; }
.radar .chip { background: rgba(255,255,255,.7); border: 1px solid rgba(0,0,0,.06); border-radius: 99px; padding: .25rem .6rem; font-size: .78rem; font-weight: 600; }

/* ---------- Day list ---------- */
.day-list { display: flex; flex-direction: column; gap: 1.2rem; }
.slot-group h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .6rem; }
.task-row {
  display: flex; align-items: center; gap: .85rem;
  padding: .8rem .9rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  transition: background .15s;
}
.task-row:hover { background: var(--surface-2); }
.task-row.done { opacity: .55; }
.task-row.done .task-title { text-decoration: line-through; }
.task-check {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line);
  background: var(--surface); flex: none; display: grid; place-items: center; color: #fff; font-size: .8rem;
}
.task-row.done .task-check { background: var(--good); border-color: var(--good); }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: .95rem; }
.task-meta { display: flex; gap: .4rem; margin-top: .25rem; flex-wrap: wrap; }
.badge {
  font-size: .7rem; font-weight: 700; padding: .15rem .5rem; border-radius: 99px;
  background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line);
}
.badge.quest { background: var(--brand-soft); color: var(--brand-ink); border-color: #c7d2fe; }
.badge.haute { background: var(--bad-soft); color: var(--bad); border: none; }
.badge.xp { background: var(--brand-soft); color: var(--brand-ink); border: none; }
.task-del { border: none; background: none; color: var(--muted); font-size: 1.1rem; padding: .2rem .4rem; border-radius: 8px; }
.task-del:hover { color: var(--bad); background: var(--bad-soft); }
.empty-state { text-align: center; color: var(--muted); padding: 1.5rem; font-size: .9rem; }

/* ---------- Campaign / objective ---------- */
.campaign-hero {
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); color: #fff; border: none;
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
}
.campaign-hero .eyebrow { color: rgba(255,255,255,.7); }
.campaign-hero h2 { font-size: 1.35rem; margin-top: .2rem; }
.campaign-hero .muted { color: rgba(255,255,255,.75); margin-top: .5rem; }
.campaign-countdown { text-align: center; }
.campaign-countdown strong { display: block; font-size: 2.8rem; font-weight: 800; color: var(--accent); line-height: 1; }
.campaign-countdown span { font-size: .8rem; color: rgba(255,255,255,.7); }

/* minmax(0,1fr) : sans lui, une carte au contenu large (ex « 11 700 / 12 000 abonnés »)
   empêche la colonne de rétrécir et toute la grille déborde de l'écran. */
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.metric-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .4rem; min-width: 0;
}
.metric-card > span { font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.metric-card strong { font-size: 2rem; font-weight: 800; }
.metric-card small { color: var(--muted); font-size: .76rem; }
.metric-fraction { display: flex; align-items: baseline; gap: .3rem; flex-wrap: wrap; min-width: 0; }
.mf-den { font-size: 1.1rem; color: var(--muted); font-weight: 600; }
.kpi-card { background: linear-gradient(135deg, var(--brand-soft), var(--mix)); border-color: color-mix(in srgb, var(--brand) 20%, var(--line)); }
.kpi-card strong { color: var(--brand-ink); }
.goal-card.goal-done { border-color: color-mix(in srgb, var(--good) 30%, var(--line)); background: linear-gradient(135deg, color-mix(in srgb, var(--good) 10%, var(--mix)), var(--mix)); }
.goal-card .stepper { display: flex; gap: .4rem; margin-top: .4rem; }
.goal-input-row { display: flex; align-items: baseline; gap: .5rem; }
.goal-input { width: 6.5rem; font-size: 1.5rem; font-weight: 800; padding: .2rem .4rem; }
.goal-target { font-size: 1rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.goal-card .goal-bar { height: 9px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: .2rem; }
.goal-card .goal-bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), #818cf8); transition: width .4s; }
.goal-card .goal-bar.done span { background: linear-gradient(90deg, var(--good), #4ade80); }
.goal-caption { color: var(--muted); font-size: .74rem; }
.stepper-btn { border: 1px solid var(--line); background: var(--surface-2); border-radius: 9px; padding: .4rem .7rem; font-weight: 700; font-size: .82rem; }
.stepper-btn:hover { background: var(--brand-soft); border-color: #c7d2fe; }

.section-label { margin: .3rem 0 -.4rem; }
.section-label h3 { font-size: 1.05rem; }
.section-label .eyebrow { margin-bottom: .15rem; }
.overview-group {
  display: inline-block; margin: 1rem 0 .6rem; padding: .25rem .7rem;
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  border-radius: 99px;
}
.overview-grid { margin-bottom: .2rem; }
.card-accent { background: linear-gradient(135deg, var(--brand-soft), var(--mix)); border-color: color-mix(in srgb, var(--brand) 20%, var(--line)); }
.card-accent strong { color: var(--brand-ink); }
.week-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 700px) { .week-grid { grid-template-columns: 1fr; } }
.objective-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.daily-goals, .weekly-goals { display: flex; flex-direction: column; gap: .8rem; }
.goal-line { display: flex; flex-direction: column; gap: .35rem; }
.goal-line-top { display: flex; justify-content: space-between; align-items: center; font-size: .88rem; font-weight: 600; }
.goal-line-top .gl-val { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.goal-bar { height: 9px; border-radius: 99px; background: var(--line); overflow: hidden; }
.goal-bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), #818cf8); transition: width .4s; }
.goal-bar.done span { background: linear-gradient(90deg, var(--good), #4ade80); }
.reminder-block { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.channel-split { display: flex; gap: 1rem; margin-top: .5rem; flex-wrap: wrap; }
.channel-split span { font-size: .85rem; color: var(--ink-soft); }
.channel-split strong { color: var(--ink); }

/* ---------- Niveau ---------- */
.level-hero {
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); color: #fff; border: none;
  text-align: center; padding: 2rem;
}
.level-badge {
  width: 96px; height: 96px; margin: 0 auto 1rem; border-radius: 50%;
  display: grid; place-items: center; font-size: 2.6rem;
  background: rgba(255,255,255,.12); border: 3px solid rgba(255,255,255,.3);
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
.level-hero h2 { font-size: 1.8rem; }
.level-hero .level-sub { color: rgba(255,255,255,.8); margin-top: .3rem; }
.level-xpbar { max-width: 380px; margin: 1.2rem auto 0; }
.level-xpbar .progress-track { height: 12px; }
.level-xpbar small { display: block; margin-top: .5rem; color: rgba(255,255,255,.75); font-size: .8rem; }
.niveau-top { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.2rem; }
.niveau-two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 800px) { .niveau-top, .niveau-two { grid-template-columns: 1fr; } }

/* Bannière saison */
.season-banner {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  background: linear-gradient(135deg, #4f46e5, #6366f1); color: #fff;
  border-radius: 14px; padding: .7rem 1rem; font-size: .9rem; font-weight: 600;
}
.season-pill { background: rgba(255,255,255,.2); padding: .2rem .7rem; border-radius: 99px; font-weight: 800; font-size: .8rem; }
.season-info { color: rgba(255,255,255,.92); }
.season-legend { margin-left: auto; color: rgba(255,255,255,.92); }

/* Boucliers de rang */
.rank-shield {
  position: relative; width: 88px; height: 96px; flex: none; display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 1.7rem; text-shadow: 0 1px 2px rgba(0,0,0,.35);
  clip-path: polygon(50% 0, 100% 14%, 100% 60%, 50% 100%, 0 60%, 0 14%);
  background:
    radial-gradient(circle at 50% 22%, rgba(255,255,255,.6), transparent 52%),
    linear-gradient(160deg, var(--c1, #e0a36b), var(--c2, #a16207));
  box-shadow: inset 0 2px 6px rgba(255,255,255,.45), inset 0 -8px 16px rgba(0,0,0,.3);
}
.rank-shield span { position: relative; z-index: 2; }
/* Reflet diagonal qui balaie le bouclier (hero uniquement) */
.rank-shield.is-hero::after {
  content: ''; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(115deg, transparent 38%, rgba(255,255,255,.65) 50%, transparent 62%);
  transform: translateX(-130%); animation: shieldShine 5s ease-in-out infinite;
}
@keyframes shieldShine { 0%, 55% { transform: translateX(-130%); } 78%, 100% { transform: translateX(130%); } }
.rank-shield.sm { width: 34px; height: 38px; font-size: .8rem; }
.rank-shield--bronze  { --c1: #f0b984; --c2: #a16207; }
.rank-shield--argent  { --c1: #f4f7fb; --c2: #94a3b8; color: #334155; text-shadow: none; }
.rank-shield--or      { --c1: #fde68a; --c2: #d97706; }
.rank-shield--platine { --c1: #a7f3d0; --c2: #14b8a6; }
.rank-shield--diamant { --c1: #c7dbff; --c2: #3b82f6; }
.rank-shield--legende { --c1: #fde68a; --c2: #a855f7; }

/* Hero rang */
.rank-hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(255,255,255,.06), transparent 45%),
    linear-gradient(135deg, var(--hero-1), var(--hero-2) 70%);
  color: #fff; border: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 1.6rem; flex-wrap: wrap;
  box-shadow: 0 18px 50px rgba(2,6,23,.45);
}
/* Halo de lumière coloré selon le rang */
.rank-hero::before {
  content: ''; position: absolute; top: -55%; left: -8%; width: 560px; height: 560px;
  background: radial-gradient(circle, var(--glow, rgba(99,102,241,.4)), transparent 68%);
  pointer-events: none; filter: blur(6px);
}
.rank-hero::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.05), transparent 30%);
}
.rank-hero > * { position: relative; z-index: 1; }
.rank-hero--bronze  { --glow: rgba(217,138,67,.4); }
.rank-hero--argent  { --glow: rgba(148,163,184,.42); }
.rank-hero--or      { --glow: rgba(245,158,11,.42); }
.rank-hero--platine { --glow: rgba(20,184,166,.42); }
.rank-hero--diamant { --glow: rgba(59,130,246,.45); }
.rank-hero--legende { --glow: rgba(168,85,247,.5); }
.rank-hero .eyebrow { color: rgba(255,255,255,.6); }
.rank-hero .rank-shield.is-hero {
  filter: drop-shadow(0 8px 18px var(--glow, rgba(0,0,0,.4)));
  transform: scale(1.04);
}
.rank-hero-main { flex: 1; min-width: 220px; }
.rank-hero-main h2 { font-size: 2rem; margin: .1rem 0 .7rem; letter-spacing: -.02em; text-shadow: 0 2px 12px rgba(0,0,0,.3); }
.rank-progress {
  height: 13px; border-radius: 99px; overflow: hidden;
  background: rgba(255,255,255,.12); box-shadow: inset 0 1px 3px rgba(0,0,0,.4);
}
.rank-progress span {
  display: block; height: 100%; border-radius: 99px; transition: width .5s ease;
  background: linear-gradient(90deg, var(--brand), #818cf8);
  box-shadow: 0 0 12px rgba(99,102,241,.5);
}
.rank-sub { margin-top: .5rem; color: rgba(255,255,255,.8); font-size: .85rem; font-weight: 600; }
.rank-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.rstat { background: linear-gradient(160deg, rgba(255,255,255,.1), rgba(255,255,255,.04)); border: 1px solid rgba(255,255,255,.12); border-radius: 13px; padding: .55rem .85rem; min-width: 104px; box-shadow: inset 0 1px 0 rgba(255,255,255,.08); }
.rstat strong { display: block; font-size: 1.15rem; }
.rstat span { font-size: .68rem; color: rgba(255,255,255,.6); text-transform: uppercase; letter-spacing: .03em; }

/* Quêtes */
.quest-head { display: flex; align-items: center; gap: .6rem; }
.button.sm { padding: .4rem .7rem; font-size: .8rem; }
.quest-habits {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-top: .9rem; padding: .8rem .9rem; border: 1px dashed var(--line); border-radius: 12px; background: var(--surface-2);
  font-size: .9rem; font-weight: 600;
}
.quest-habits strong { font-size: 1.1rem; color: var(--brand-ink); }

/* Échelle */
.echelle-list { max-height: 460px; overflow-y: auto; display: flex; flex-direction: column; gap: .3rem; padding-right: .3rem; }
.ech-row { display: flex; align-items: center; gap: .7rem; padding: .4rem .5rem; border-radius: 10px; }
.ech-row.locked { opacity: .5; }
.ech-row.current { background: var(--brand-soft); box-shadow: inset 0 0 0 1px #c7d2fe; }
.ech-name { font-weight: 700; font-size: .9rem; }
.ech-xp { margin-left: auto; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ech-reward { margin: 0 0 .2rem 2.6rem; font-size: .76rem; color: var(--brand-ink); background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line)); border-radius: 8px; padding: .25rem .6rem; display: inline-flex; align-items: center; }

.legend-goal { display: flex; flex-direction: column; justify-content: center; gap: .6rem; }
.legend-goal h3 { font-size: 1.3rem; }
.legend-goal .progress-track { height: 12px; background: var(--line); }
.legend-goal .progress-track span { background: linear-gradient(90deg, var(--brand), #818cf8); }

.quest-list { display: flex; flex-direction: column; gap: .6rem; margin-bottom: .8rem; }
.quest-add { display: flex; flex-direction: column; gap: .5rem; }
.quest-input { padding: .6rem .7rem; }

.habits-mini { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; }
.habit-ring {
  width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center;
  font-size: 2.4rem; font-weight: 800; margin: .4rem 0; line-height: 1;
  background: conic-gradient(var(--ring, var(--good)) var(--p,0%), var(--line) 0);
  position: relative;
}
.habit-ring::before { content: ''; position: absolute; inset: 10px; background: var(--surface); border-radius: 50%; }
.habit-ring .hr-num { position: relative; }
.habit-ring .hr-den { position: relative; font-size: .9rem; color: var(--muted); font-weight: 700; }

.rank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
.rank-card {
  border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem; text-align: center;
  background: var(--surface); opacity: .5;
}
.rank-card.reached { opacity: 1; border-color: #c7d2fe; background: var(--brand-soft); }
.rank-card.current { box-shadow: 0 0 0 2px var(--brand); }
.rank-card .rc-ico { font-size: 2rem; }
.rank-card .rc-name { font-weight: 700; margin: .3rem 0; }
.rank-card .rc-xp { font-size: .76rem; color: var(--muted); }
.rank-card .rc-reward { font-size: .76rem; color: var(--ink-soft); margin-top: .35rem; }

/* ---------- Analytics ---------- */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.funnel { display: flex; flex-direction: column; gap: .6rem; }
.funnel-row { display: flex; flex-direction: column; gap: .3rem; }
.funnel-row .fr-top { display: flex; justify-content: space-between; font-size: .85rem; font-weight: 600; }
.funnel-bar { height: 30px; border-radius: 9px; background: var(--brand); color: #fff; display: flex; align-items: center; padding: 0 .6rem; font-size: .8rem; font-weight: 700; min-width: 40px; transition: width .4s; }
.funnel-row:nth-child(1) .funnel-bar { background: #818cf8; }
.funnel-row:nth-child(2) .funnel-bar { background: #6366f1; }
.funnel-row:nth-child(3) .funnel-bar { background: #4f46e5; }
.funnel-row:nth-child(4) .funnel-bar { background: var(--accent); }
.channel-list { display: flex; flex-direction: column; gap: .8rem; }
.channel-item { display: flex; flex-direction: column; gap: .3rem; }
.channel-item .ci-top { display: flex; justify-content: space-between; font-size: .85rem; font-weight: 600; }
.channel-item .ci-bar { height: 9px; border-radius: 99px; background: var(--line); overflow: hidden; }
.channel-item .ci-bar span { display: block; height: 100%; background: linear-gradient(90deg, #14b8a6, #2dd4bf); }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.2rem; }
.stack-form { display: flex; flex-direction: column; gap: .8rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
label { display: flex; flex-direction: column; gap: .35rem; font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.label-hint { color: var(--muted); font-weight: 500; font-size: .9em; }
.check-line { flex-direction: row; align-items: center; gap: .5rem; cursor: pointer; margin-top: -.3rem; }
.check-line input { width: 17px; height: 17px; accent-color: var(--brand); flex: none; cursor: pointer; }
input, select, textarea {
  font: inherit; font-weight: 500; color: var(--ink);
  padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.button-stack { display: flex; flex-direction: column; gap: .6rem; }
.file-button { position: relative; overflow: hidden; text-align: center; cursor: pointer; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- Dialogs ---------- */
dialog {
  border: none; border-radius: 18px; padding: 1.6rem;
  box-shadow: 0 30px 80px rgba(15,23,42,.35); max-width: 460px; width: calc(100% - 2rem);
  color: var(--ink);
}
dialog::backdrop { background: rgba(15,23,42,.5); backdrop-filter: blur(2px); }
.modal-form { display: flex; flex-direction: column; gap: .9rem; }
.modal-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.modal-heading h2 { font-size: 1.2rem; }
.icon-button { border: none; background: var(--surface-2); width: 34px; height: 34px; border-radius: 10px; font-size: 1.3rem; color: var(--ink-soft); }
.icon-button:hover { background: var(--line); }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .4rem; }
.plan-fields { display: flex; flex-direction: column; gap: .6rem; margin: 1rem 0; }
.plan-input { padding: .7rem .8rem; }

.rankup-modal { text-align: center; max-width: 380px; }
.rankup-inner { display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.rankup-eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: .7rem; font-weight: 700; color: var(--brand); }
.rankup-badge { width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center; color: var(--brand); background: linear-gradient(135deg, var(--brand-soft), var(--mix)); border: 3px solid var(--brand); margin: .5rem 0; animation: pop .4s cubic-bezier(.22,1.4,.5,1); }
.rankup-badge svg { width: 52px; height: 52px; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.rankup-modal h2 { font-size: 1.8rem; }
.rankup-reward { color: var(--ink-soft); margin: .3rem 0 1rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: .7rem 1.2rem; border-radius: 12px;
  font-size: .9rem; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.3);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- KPI tracker ---------- */
.kpi-hero {
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); color: #fff; border: none;
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
}
.kpi-hero .eyebrow { color: rgba(255,255,255,.7); }
.kpi-hero h2 { font-size: 1.5rem; }
.kpi-hero .muted { color: rgba(255,255,255,.72); margin-top: .4rem; }
.kpi-month-switch { display: inline-flex; background: rgba(255,255,255,.1); border-radius: 12px; padding: 4px; gap: 4px; }
.kpi-month-btn {
  border: none; background: transparent; color: rgba(255,255,255,.8);
  padding: .5rem .9rem; border-radius: 9px; font-weight: 700; font-size: .85rem;
}
.kpi-month-btn.active { background: #fff; color: #1a1a24; box-shadow: 0 2px 8px rgba(0,0,0,.25); }

.kpi-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: .8rem; }
.kpi-overview { display: flex; flex-direction: column; gap: 1.2rem; }
.kpi-ov-metrics { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
/* Panneau Performance — compact & centré pour ne pas masquer le tableau */
.kpi-perf-panel { padding: 1rem 1.2rem; }
.kpi-perf-panel .panel-heading { justify-content: center; text-align: center; margin-bottom: .7rem; }
.kpi-perf-panel .panel-heading h2 { font-size: 1.05rem; }
.kpi-rates { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; }
.kpi-rate { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .25rem; }
.kr-val { font-size: 1.35rem; font-weight: 800; color: var(--brand-ink); font-variant-numeric: tabular-nums; line-height: 1; }
.kr-label { font-size: .76rem; font-weight: 600; color: var(--ink-soft); }
.kr-bar { width: 100%; max-width: 110px; height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: .15rem; }
.kr-bar span { display: block; height: 100%; border-radius: 99px; background: var(--brand); transition: width .4s; }
.kpi-stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: .85rem 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .25rem;
}
.kpi-stat span { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.kpi-stat strong { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi-stat.accent { background: linear-gradient(135deg, var(--brand-soft), var(--mix)); border-color: color-mix(in srgb, var(--brand) 20%, var(--line)); }
.kpi-stat.accent strong { color: var(--brand-ink); }

.kpi-table-panel { padding-bottom: .6rem; }
/* Contrôle de taille de police des tableaux */
.table-fs { display: inline-flex; align-items: center; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.fs-btn { border: none; background: transparent; color: var(--ink-soft); width: 30px; height: 28px; border-radius: 7px; font-weight: 700; line-height: 1; display: grid; place-items: center; }
.fs-btn:hover:not(:disabled) { background: var(--surface); color: var(--ink); }
.fs-btn:disabled { opacity: .3; cursor: default; }
.fs-btn.fs-small { font-size: .78rem; }
.fs-btn.fs-large { font-size: 1.05rem; }
/* Les tableaux (KPI & habitudes) restent en clair, même en mode sombre, pour rester lisibles */
.kpi-table-wrap {
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --ink: #1a1a24;
  --ink-soft: #5c5c6b;
  --muted: #9c9caa;
  --line: #e7e7ec;
  --brand-soft: #eeeefd;
  --brand-ink: #4a45d6;
  color-scheme: light; /* garde les flèches natives des champs nombre visibles même en mode sombre */
  overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.kpi-name { cursor: pointer; border-radius: 4px; padding: 0 2px; }
.kpi-name:hover { color: var(--brand-ink); text-decoration: underline; }
.kpi-table { border-collapse: collapse; width: 100%; table-layout: fixed; font-size: var(--table-fs, 12.8px); }
#kpiTable { min-width: 1040px; }
#habitTable { min-width: 860px; }
.kpi-table th, .kpi-table td { border: 1px solid var(--line); padding: 0; text-align: center; }
.kpi-table thead th { background: var(--surface-2); font-weight: 700; color: var(--ink-soft); padding: .4rem .5rem; position: sticky; top: 0; }
.kpi-group-row th { font-size: .87em; text-transform: uppercase; letter-spacing: .06em; font-weight: 800; padding: .45rem .5rem; }
.kpi-grp--contenu  { background: #ecfeff; color: #0e7490; }
.kpi-grp--settings { background: var(--brand-soft); color: var(--brand-ink); }
.kpi-grp--closing  { background: #fff7ed; color: #b45309; }
.kpi-col-h { white-space: normal; font-size: .9em; word-break: break-word; }
/* Séparateur entre les sections */
.kpi-group-start { border-left: 2px solid #cbd5e1 !important; }
.kpi-day-h { background: var(--surface-2); position: sticky; left: 0; z-index: 3; width: 70px; }
.kpi-day { background: var(--surface-2); font-weight: 700; color: var(--ink-soft); white-space: nowrap; padding: 0 .6rem; position: sticky; left: 0; z-index: 1; text-align: right; min-width: 64px; }
.kpi-table tbody tr:nth-child(even) td { background: #fcfcfd; }
.kpi-table tbody tr:hover td { background: var(--brand-soft); }
.kpi-input {
  border: none; background: transparent; width: 100%; min-width: 0;
  padding: .45rem .25rem; font-size: 1em; text-align: center; border-radius: 0;
  font-variant-numeric: tabular-nums;
}
.kpi-input.kpi-t-money { min-width: 0; }
.kpi-input:focus { outline: 2px solid var(--brand); outline-offset: -2px; background: #fff; box-shadow: none; }
.kpi-yn { -webkit-appearance: none; appearance: none; cursor: pointer; }
.kpi-totals-row th, .kpi-totals-row td {
  background: var(--ink); color: #fff; font-weight: 800; padding: .5rem .4rem;
  font-variant-numeric: tabular-nums;
}
.kpi-totals-row th { position: sticky; left: 0; z-index: 2; text-align: right; }
/* La ligne total (1re du tbody) ne doit pas être rayée */
.kpi-table tbody tr.kpi-totals-row td { background: var(--ink); }
.kpi-total-cell { white-space: nowrap; }

/* ---------- Habit tracker ---------- */
.habit-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .8rem; }
.habit-summary .metric-card strong.sm { font-size: 1rem; line-height: 1.3; }
.habit-table th, .habit-table td { border: 1px solid var(--line); }
.habit-rate-h { background: var(--surface-2); position: sticky; top: 0; z-index: 2; font-size: .9em; padding: .4rem .5rem; width: 66px; }
.habit-col-h {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2);
  font-size: .9em; font-weight: 700; padding: .4rem .4rem;
  white-space: normal; word-break: break-word; vertical-align: middle;
}
.habit-name { cursor: pointer; }
.habit-name:hover { color: var(--brand-ink); text-decoration: underline; }
.habit-del {
  display: inline-grid; place-items: center; margin-left: .25rem; width: 16px; height: 16px;
  border: none; background: transparent; color: var(--muted); font-size: .9rem; border-radius: 4px; line-height: 1;
}
.habit-del:hover { background: var(--bad-soft); color: var(--bad); }
.habit-avg-row th, .habit-avg-row td { background: #f1f5f9; font-weight: 800; }
.habit-cell {
  height: 30px; text-align: center; cursor: pointer;
  font-weight: 800; color: #1a3b1a; user-select: none; transition: filter .1s;
}
.habit-cell:hover { filter: brightness(.94); }
/* Préfixe .habit-table obligatoire : sans lui, la zébrure .kpi-table tbody tr:nth-child(even) td
   est plus spécifique et efface la couleur une ligne sur deux. */
.habit-table .habit-cell.v1  { background: #b6d7a8; }   /* vert */
.habit-table .habit-cell.v05 { background: #f9cb9c; color: #7c4a12; }   /* orange */
.habit-table .habit-cell.v0  { background: #ea9999; color: #7a1414; }   /* rouge */
.habit-score { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; padding: .3rem .4rem; min-width: 58px; }
.habit-table .habit-score.v1  { background: #d9ead3; color: #38761d; }
.habit-table .habit-score.v05 { background: #fce5cd; color: #b45309; }
.habit-table .habit-score.v0  { background: #f4cccc; color: #cc0000; }

/* ---------- Contenu (planning) ---------- */
.content-hero { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.content-hero .muted { margin-top: .3rem; }
.content-filters { display: flex; flex-wrap: wrap; gap: .5rem; }
.ct-chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  padding: .4rem .8rem; border-radius: 99px; font-size: .82rem; font-weight: 600;
}
.ct-chip:hover { background: var(--surface-2); }
.ct-chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.ct-chip[style*="--ctc"].active { background: var(--ctc); border-color: var(--ctc); }

.content-group { margin-top: 1.2rem; }
.content-date {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin-bottom: .5rem;
}
.content-cards { display: flex; flex-direction: column; gap: .6rem; }
.content-card {
  display: flex; align-items: center; gap: 1rem;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: 12px; padding: .8rem 1rem; box-shadow: var(--shadow);
}
.content-card:hover { background: var(--surface-2); }
.cc-main { flex: 1; min-width: 0; cursor: pointer; border-radius: 8px; }
.cc-main:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.cc-title { font-weight: 600; font-size: .95rem; display: flex; align-items: center; gap: .4rem; }
.cc-note-ic { width: 14px; height: 14px; color: var(--muted); flex: none; }
.cc-note {
  margin-top: .5rem; font-size: .83rem; line-height: 1.45; color: var(--ink-soft);
  white-space: pre-wrap; max-height: 4.4em; overflow: hidden;
  padding: .5rem .65rem; background: var(--surface-2); border-radius: 8px;
  border: 1px solid var(--line);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.cc-meta { display: flex; align-items: center; gap: .5rem; margin-top: .4rem; flex-wrap: wrap; }
.ct-badge { font-size: .72rem; font-weight: 700; padding: .15rem .55rem; border-radius: 99px; }
.ct-status {
  display: inline-flex; align-items: center; gap: .35rem; border: none; cursor: pointer;
  font-size: .72rem; font-weight: 700; padding: .15rem .55rem; border-radius: 99px;
}
.ct-status:hover { filter: brightness(.96); }
.ct-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.cc-overdue {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; font-weight: 700; padding: .15rem .55rem; border-radius: 99px;
  color: var(--bad); background: var(--bad-soft);
}
.cc-overdue svg { width: 13px; height: 13px; }
.content-card.is-overdue { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.content-section {
  display: flex; align-items: center; gap: .7rem; margin: 1.6rem 0 .2rem;
  font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}
.content-section::after { content: ''; flex: 1; height: 1px; background: var(--line); }
/* Le contenu déjà posté est atténué (moins prioritaire) */
.content-section ~ .content-group { opacity: .62; }
.content-section ~ .content-group:hover { opacity: 1; }
.cc-actions { display: flex; gap: .3rem; flex: none; }
.cc-btn { border: none; background: var(--surface-2); color: var(--ink-soft); width: 30px; height: 30px; border-radius: 8px; font-size: .95rem; display: inline-grid; place-items: center; }
.cc-btn:hover { background: var(--line); }
.cc-btn svg { width: 15px; height: 15px; }
.cc-dup:hover { background: color-mix(in srgb, #3a9ca8 20%, var(--surface-2)); color: #3a9ca8; }
.cc-del:hover { background: var(--bad-soft); color: var(--bad); }

/* ---------- Productivité (analyse IA) ---------- */
.prod-hero { background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); color: #fff; border: none; }
.prod-hero .eyebrow { color: rgba(255,255,255,.7); }
.prod-hero .muted { color: rgba(255,255,255,.75); margin-top: .4rem; max-width: 620px; }
.prod-form { display: flex; flex-direction: column; gap: 1.2rem; }
.prod-form label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; font-size: .85rem; }
.prod-full { width: 100%; }
.prod-section { display: flex; flex-direction: column; gap: .8rem; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.prod-section > .eyebrow { margin: 0; }
.prod-hint { margin: -.3rem 0 0; font-size: .8rem; }
.prod-screen-total { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.prod-apps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; }
#prodAnalyze { align-self: flex-start; }
#prodStatus { width: 100%; margin: 0; }

/* Bannière « temps à rien faire » */
.prod-wasted {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem 1.2rem; margin-bottom: 1rem; border-radius: 12px;
  background: color-mix(in srgb, var(--bad) 12%, var(--mix)); border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
}
.prod-wasted-label { font-weight: 700; font-size: .9rem; color: var(--bad); }
.prod-wasted-label svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 7px; }
.prod-wasted-val { font-size: 1.6rem; font-weight: 800; color: var(--bad); font-variant-numeric: tabular-nums; }

/* Objectifs de temps */
.prod-goals { display: flex; flex-direction: column; gap: .4rem; margin: 1rem 0; }
.prod-goals .eyebrow { margin-bottom: .2rem; }
.prod-goal { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: .8rem; padding: .5rem .8rem; border-radius: 9px; border: 1px solid var(--line); font-size: .85rem; }
.prod-goal-name { font-weight: 600; }
.prod-goal-val { font-variant-numeric: tabular-nums; font-weight: 700; }
.prod-goal-limit { color: var(--ink-soft); font-weight: 500; }
.prod-goal-badge { font-size: .78rem; font-weight: 700; white-space: nowrap; }
.prod-goal--ok { border-left: 3px solid var(--good); background: color-mix(in srgb, var(--good) 6%, var(--mix)); }
.prod-goal--ok .prod-goal-badge { color: var(--good); }
.prod-goal--over { border-left: 3px solid var(--bad); background: color-mix(in srgb, var(--bad) 7%, var(--mix)); }
.prod-goal--over .prod-goal-badge { color: var(--bad); }

/* Bouton kebab (⋮) & fenêtre des objectifs */
.kebab-button {
  flex: none; border: none; background: transparent; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; color: var(--ink-soft); cursor: pointer;
}
.kebab-button svg { width: 18px; height: 18px; }
.kebab-button:hover { background: var(--surface-2); color: var(--ink); }
.prod-goals-modal { max-width: 540px; }
.prod-goals-modal[open] { display: flex; flex-direction: column; gap: 1rem; }
.prod-goals-modal .prod-apps-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.prod-goals-modal label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; font-size: .85rem; }

.prod-result { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: flex-start; }
.prod-score {
  flex: none; width: 150px; height: 150px; border-radius: 50%; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--sc) 18%, var(--mix)), var(--mix));
  border: 4px solid var(--sc); box-shadow: 0 8px 24px color-mix(in srgb, var(--sc) 30%, transparent);
}
.prod-score-num { font-size: 3rem; font-weight: 800; line-height: 1; color: var(--sc); }
.prod-score-sub { font-size: .8rem; color: var(--ink-soft); font-weight: 600; margin-top: .25rem; }
.prod-result-main { flex: 1; min-width: 260px; }
.prod-summary { margin: 1rem 0; font-size: .95rem; line-height: 1.55; }
.prod-apps { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.prod-app { display: flex; justify-content: space-between; padding: .45rem .7rem; border-radius: 9px; border: 1px solid var(--line); font-size: .85rem; }
.prod-app-name { font-weight: 600; }
.prod-app-min { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.prod-app--productif { border-left: 3px solid var(--good); }
.prod-app--distrayant { border-left: 3px solid var(--bad); }
.prod-app--neutre { border-left: 3px solid var(--muted); }
.prod-tips ul { margin: .4rem 0 0; padding-left: 1.1rem; font-size: .88rem; line-height: 1.5; color: var(--ink-soft); }

#prodHistory { display: flex; flex-direction: column; gap: .5rem; }
.prod-hist-row { display: flex; align-items: center; gap: 1rem; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 11px; padding: .6rem .9rem; }
.prod-hist-row:hover { background: var(--surface-2); }
.prod-hist-row.active { box-shadow: inset 0 0 0 2px var(--brand); }
.prod-hist-score { font-size: 1.3rem; font-weight: 800; width: 44px; font-variant-numeric: tabular-nums; }
.prod-hist-date { flex: 1; font-weight: 600; font-size: .9rem; text-transform: capitalize; }
.prod-hist-verdict { font-size: .78rem; color: var(--muted); font-weight: 700; }

/* ---------- Nutrition (calories & macros) ---------- */
.nutri-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem; margin-bottom: 1.1rem; }
.nutri-card {
  display: flex; flex-direction: column; gap: .35rem; min-width: 0;
  padding: .9rem 1rem; border-radius: 14px; border: 1px solid var(--line);
  background: linear-gradient(160deg, color-mix(in srgb, var(--nc) 7%, var(--surface)), var(--surface));
  box-shadow: var(--shadow);
}
.nutri-card-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.nutri-card-val { display: flex; align-items: baseline; gap: .35rem; min-width: 0; }
.nutri-card-val .nc-num { font-size: 1.5rem; font-weight: 800; line-height: 1; color: var(--nc); font-variant-numeric: tabular-nums; }
.nutri-card-val .nc-den { font-size: .78rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.nutri-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: .25rem; }
.nutri-bar > span { display: block; height: 100%; border-radius: 3px; background: var(--nc); transition: width .4s ease; }
.nutri-card--over { border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.nutri-card--over .nc-num { color: var(--bad); }
.nutri-card--over .nutri-bar > span { background: var(--bad); }

.nutri-left { flex: none; font-size: .8rem; font-weight: 600; white-space: nowrap; margin-left: auto; }
.nutri-left.nutri-over { color: var(--bad); }
.nutri-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
#nutriStatus { margin: 0; font-size: .82rem; }

/* Produits favoris */
.nutri-fav { display: flex; flex-direction: column; gap: .5rem; }
.nutri-fav .eyebrow { margin: 0; }
.nutri-fav-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.nutri-chip {
  display: inline-flex; align-items: center; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); font-size: .82rem;
}
.nutri-chip > button { border: none; background: transparent; cursor: pointer; color: var(--ink); font-weight: 600; padding: .35rem .3rem .35rem .8rem; }
.nutri-chip > button:hover { color: var(--brand); }
.nutri-chip .nutri-chip-x { color: var(--muted); font-size: .9rem; padding: .35rem .7rem .35rem .3rem; font-weight: 700; }
.nutri-chip .nutri-chip-x:hover { color: var(--bad); }

/* Photo attachée (miniature + retirer) avant analyse */
.nutri-photo-attach {
  display: flex; align-items: center; gap: .8rem; min-width: 0;
  padding: .7rem .8rem; border-radius: 12px;
  border: 1px dashed color-mix(in srgb, var(--brand) 40%, var(--line));
  background: color-mix(in srgb, var(--brand) 4%, var(--mix));
}
.nutri-photo-attach img { width: 52px; height: 52px; object-fit: cover; border-radius: 9px; flex: none; }
.nutri-photo-attach .npa-txt { flex: 1; min-width: 0; font-size: .82rem; display: flex; flex-direction: column; gap: .15rem; }
.nutri-photo-attach .npa-txt span { color: var(--ink-soft); }
.nutri-photo-attach > button { flex: none; border: none; background: transparent; color: var(--muted); font-size: 1.1rem; padding: .2rem .45rem; border-radius: 8px; cursor: pointer; }
.nutri-photo-attach > button:hover { color: var(--bad); background: var(--bad-soft); }

/* Aperçu de l'analyse IA */
.nutri-preview {
  display: flex; flex-direction: column; gap: .7rem; padding: 1rem 1.1rem; border-radius: 13px;
  border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent);
  background: color-mix(in srgb, var(--brand) 6%, var(--mix));
}
.nutri-preview-title { font-weight: 700; font-size: .95rem; }
.nutri-preview-macros { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .84rem; font-weight: 600; color: var(--ink-soft); }
.nutri-preview-macros span { display: inline-flex; align-items: center; gap: .4rem; font-variant-numeric: tabular-nums; }
.nutri-preview-macros i { width: 8px; height: 8px; border-radius: 50%; background: var(--nc); }
.nutri-preview-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.nutri-preview-actions .button { font-size: .82rem; padding: .5rem .9rem; }

/* Réponse du coach */
.nutri-coach { padding: 1rem 1.1rem; border-radius: 13px; border: 1px solid var(--line); background: var(--surface-2); }
.nutri-coach .eyebrow { margin: 0 0 .5rem; }
.nutri-coach-body { font-size: .88rem; line-height: 1.6; color: var(--ink-soft); }
.nutri-coach-body b { color: var(--ink); }

/* Journal + colonne latérale */
.nutri-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1.1rem; align-items: start; margin-top: 1.1rem; }
.nutri-side { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }
.nutri-meals { display: flex; flex-direction: column; }
.nutri-meal { display: flex; align-items: center; gap: .9rem; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.nutri-meal:last-child { border-bottom: none; }
.nutri-meal-main { flex: 1; min-width: 0; }
.nutri-meal-title { font-weight: 650; font-size: .9rem; }
.nutri-meal-macros { font-size: .76rem; color: var(--muted); margin-top: .15rem; font-variant-numeric: tabular-nums; }
.nutri-meal-kcal { flex: none; font-size: .88rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nutri-meal-del { flex: none; border: none; background: transparent; color: var(--muted); font-size: 1rem; padding: .2rem .4rem; border-radius: 8px; cursor: pointer; }
.nutri-meal-del:hover { color: var(--bad); background: var(--bad-soft); }

/* Historique 7 jours */
.nutri-hist { display: grid; gap: .5rem; }
.nutri-hist-col { min-width: 0; text-align: center; }
.nutri-hist-bar { height: 72px; border-radius: 7px; background: var(--surface-2); display: flex; align-items: flex-end; overflow: hidden; }
.nutri-hist-bar > span { width: 100%; background: color-mix(in srgb, var(--brand) 45%, var(--mix)); transition: height .4s ease; }
.nutri-hist-col.today .nutri-hist-bar > span { background: var(--brand); }
.nutri-hist-day { font-size: .68rem; margin-top: .4rem; color: var(--ink-soft); font-weight: 600; }
.nutri-hist-col.today .nutri-hist-day { color: var(--ink); font-weight: 800; }
.nutri-hist-kcal { font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Poids du matin */
.nutri-weight-row { display: flex; gap: .6rem; margin-bottom: .9rem; }
.nutri-weight-row input { flex: 1; min-width: 0; }
.nutri-weight-row .button { flex: none; }
.nutri-w-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; text-align: center; }
.nutri-w-stats > div { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.nutri-w-stats span.muted { font-size: .68rem; font-weight: 600; }
.nutri-w-stats strong { font-size: .95rem; font-variant-numeric: tabular-nums; }
.nutri-delta { font-size: .85rem; }
.nutri-delta--good { color: var(--good); }
.nutri-delta--bad { color: var(--bad); }
.nutri-delta--warn { color: #c2733f; }
.nutri-delta--flat { color: var(--muted); }
.nutri-spark { width: 100%; height: 56px; margin-top: .8rem; display: block; }
.nutri-spark-x { display: flex; justify-content: space-between; font-size: .68rem; color: var(--muted); }

@media (max-width: 960px) {
  .nutri-grid { grid-template-columns: minmax(0, 1fr); }
  .nutri-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nutri-left { order: 3; width: 100%; margin-left: 0; }
}

/* ---------- To do ---------- */
.subtabs { display: inline-flex; gap: 3px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.subtab { border: none; background: transparent; color: var(--ink-soft); font-weight: 650; font-size: .88rem; padding: .45rem 1rem; border-radius: 9px; }
.subtab:hover { color: var(--ink); }
.subtab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.todo-add { display: flex; gap: .6rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.todo-add input[type="text"], .todo-add #todoInput, .todo-add #todoCatInput { flex: 1; min-width: 180px; }
.todo-add select { flex: none; }
.todo-list { display: flex; flex-direction: column; gap: .5rem; }

.todo-group { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.1rem; }
.todo-group-h {
  display: flex; align-items: center; gap: .4rem;
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft);
}
.todo-group-n { color: var(--muted); font-weight: 700; }
.todo-group--done .todo-group-h { color: var(--muted); }
.todo-prio-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pc, var(--muted)); flex: none; }

.todo-row {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2);
}
.todo-check {
  width: 22px; height: 22px; border-radius: 7px; border: 1.6px solid var(--muted);
  background: var(--surface); color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 800; flex: none;
}
.todo-row.done .todo-check { background: var(--good); border-color: var(--good); }
.todo-text { flex: 1; font-weight: 500; font-size: .92rem; word-break: break-word; min-width: 0; }
.todo-row.done .todo-text { text-decoration: line-through; color: var(--ink-soft); }
.todo-tag {
  flex: none; border: 1px solid color-mix(in srgb, var(--tc, var(--muted)) 40%, transparent);
  background: color-mix(in srgb, var(--tc, var(--muted)) 12%, var(--mix));
  color: var(--tc, var(--ink-soft)); font-size: .72rem; font-weight: 700; padding: .2rem .6rem; border-radius: 99px; white-space: nowrap;
}
.todo-tag--none { border-style: dashed; border-color: var(--line); background: transparent; color: var(--muted); font-weight: 600; }
.todo-tag:hover { filter: brightness(.97); }
.todo-prio {
  flex: none; display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  font-size: .72rem; font-weight: 700; padding: .2rem .55rem; border-radius: 99px; white-space: nowrap;
}
.todo-prio:hover { border-color: var(--pc); color: var(--pc); }
.todo-del { border: none; background: none; color: var(--muted); font-size: 1.3rem; line-height: 1; width: 28px; height: 28px; border-radius: 7px; flex: none; }
.todo-del:hover { background: var(--bad-soft); color: var(--bad); }

/* Onglet Rubriques */
.todo-cat { border: 1px solid var(--line); border-left: 3px solid var(--tc, var(--muted)); border-radius: 12px; padding: .9rem 1rem; margin-bottom: .9rem; background: var(--surface); }
.todo-cat--none { border-left-color: var(--muted); }
.todo-cat-h { display: flex; align-items: center; gap: .7rem; margin-bottom: .7rem; }
.todo-cat-name { font-weight: 700; font-size: 1rem; }
.todo-cat-count { color: var(--muted); font-size: .78rem; font-weight: 600; margin-right: auto; }
.todo-cat-del { border: none; background: var(--surface-2); color: var(--muted); width: 26px; height: 26px; border-radius: 7px; font-size: 1.1rem; line-height: 1; flex: none; }
.todo-cat-del:hover { background: var(--bad-soft); color: var(--bad); }
.todo-cat-empty { color: var(--muted); font-size: .82rem; padding: .3rem .2rem; }

.hidden { display: none !important; }

/* ---------- Deux univers : Business / Perso ---------- */
.mode-switch {
  display: flex; gap: 3px; padding: 4px; min-width: 0;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
}
.mode-btn {
  flex: 1; min-width: 0; border: none; background: transparent; cursor: pointer;
  color: var(--ink-soft); font-weight: 650; font-size: .85rem;
  padding: .45rem .5rem; border-radius: 9px;
  transition: background .15s, color .15s;
}
.mode-btn:hover { color: var(--ink); }
.mode-btn.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.nav-group { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
/* :not([hidden]) des deux côtés : un groupe masqué (autre univers) reste un voisin CSS,
   sans ça le premier groupe visible héritait d'un séparateur fantôme. */
.nav-group:not([hidden]) ~ .nav-group:not([hidden]) { margin-top: .9rem; }
.nav-group[hidden] { display: none; }

/* ---------- Entraînements (planificateur hebdo) ---------- */
.week-nav { display: flex; align-items: center; gap: .5rem; min-width: 0; flex-wrap: wrap; }
.week-nav-label { min-width: 0; }
.week-nav-label h2 { font-variant-numeric: tabular-nums; white-space: nowrap; }
.week-nav .icon-button { flex: none; font-size: 1.1rem; line-height: 1; }
#trWeekToday { flex: none; font-size: .78rem; padding: .35rem .7rem; }
#trWeekMeta { margin-left: auto; font-size: .8rem; font-weight: 600; white-space: nowrap; }

.tr-add { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.tr-add select { flex: none; }
.tr-add #trAddNote { flex: 1; min-width: 160px; }
.tr-add .button { flex: none; }

.tr-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.tr-day {
  display: flex; flex-direction: column; gap: .4rem; min-width: 0;
  padding: .6rem .5rem; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2);
}
.tr-day { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tr-day:hover { border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.tr-day .tr-session { cursor: default; }
.tr-day.today { border-color: color-mix(in srgb, var(--brand) 45%, transparent); background: color-mix(in srgb, var(--brand) 5%, var(--mix)); }
.tr-day-head { display: flex; align-items: center; justify-content: space-between; gap: .3rem; }
.tr-day-add {
  flex: none; width: 22px; height: 22px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  font-size: .95rem; font-weight: 700; line-height: 1; padding: 0;
  display: grid; place-items: center;
}
.tr-day-add:hover { background: var(--brand-soft); color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.tr-hint { margin: -.4rem 0 1rem; font-size: .8rem; }
/* ---------- Physiologie (Whoop) & bilan hebdo ---------- */
.physio-sec { margin: 1.2rem 0 .6rem; font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
#physioCards .physio-sec:first-child { margin-top: 0; }
.physio-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; }
.physio-card {
  display: flex; flex-direction: column; gap: .35rem; min-width: 0;
  padding: 1rem 1.1rem; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow);
}
.physio-label { font-size: .7rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); }
.physio-val { font-size: 1.55rem; font-weight: 800; line-height: 1.05; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.physio-val.zone-good { color: var(--good); }
.physio-val.zone-mid { color: #d97706; }
.physio-val.zone-bad { color: var(--bad); }
.physio-sub { font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.physio-delta { align-self: flex-start; font-size: .7rem; font-weight: 700; padding: .18rem .55rem; border-radius: 999px; font-variant-numeric: tabular-nums; }
.physio-delta.good { color: var(--good); background: var(--good-soft); }
.physio-delta.bad { color: var(--bad); background: var(--bad-soft); }
.physio-delta.flat { color: var(--muted); background: var(--surface-2); }
.physio-spark { width: 100%; height: 42px; margin-top: auto; }
.physio-spark .ps-line { fill: none; stroke: var(--brand); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.physio-spark .ps-area { fill: color-mix(in srgb, var(--brand) 12%, transparent); }

.bilan { border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; margin-top: .7rem; background: var(--surface-2); }
.bilan summary { cursor: pointer; font-weight: 650; font-size: .9rem; }
.bilan-body { margin-top: .7rem; font-size: .9rem; line-height: 1.65; color: var(--ink-soft); }
.bilan-body b { color: var(--ink); }
#bilanStatus { margin: .4rem 0 0; }
#whoopConnect { text-decoration: none; display: inline-flex; align-items: center; align-self: flex-start; }

@media (max-width: 960px) {
  .physio-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Pastilles des sports connus dans la fenêtre de planification */
.trm-sports { display: flex; flex-wrap: wrap; gap: .45rem; }
.trm-sports:empty { display: none; }
.trm-chip {
  border: 1px solid var(--line); border-left: 3px solid var(--sc, var(--muted));
  background: var(--surface-2); color: var(--ink);
  border-radius: 999px; padding: .35rem .8rem;
  font-size: .82rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.trm-chip:hover { background: var(--brand-soft); color: var(--brand-ink); }
.tr-day-name { font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-soft); }
.tr-day-num { font-size: .78rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.tr-day.today .tr-day-name, .tr-day.today .tr-day-num { color: var(--brand-ink); }
.tr-day-body { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.tr-empty {
  margin: 0; font-size: .72rem; color: var(--muted); font-style: italic; padding: .2rem 0;
  border: none; background: transparent; cursor: pointer; text-align: left; font-family: inherit;
}
.tr-empty:hover { color: var(--brand); }

.tr-session {
  display: flex; align-items: center; gap: .4rem; min-width: 0;
  padding: .4rem .4rem; border-radius: 9px;
  border: 1px solid var(--line); border-left: 3px solid var(--sc);
  background: var(--surface);
}
.tr-session-main { flex: 1; min-width: 0; }
.tr-session-sport { font-size: .74rem; font-weight: 650; white-space: normal; overflow-wrap: break-word; hyphens: auto; }
.tr-session-note { font-size: .66rem; color: var(--muted); white-space: normal; overflow-wrap: break-word; hyphens: auto; }
/* Colonnes étroites : la croix se replie dans un coin et n'apparaît qu'au survol */
@media (hover: hover) and (min-width: 961px) {
  .tr-session { position: relative; }
  .tr-del { position: absolute; top: 1px; right: 1px; opacity: 0; transition: opacity .15s; background: var(--surface); }
  .tr-session:hover .tr-del, .tr-del:focus-visible { opacity: 1; }
  .tr-session.done .tr-del { background: color-mix(in srgb, var(--good) 8%, var(--mix)); }
}
.tr-session.done { background: color-mix(in srgb, var(--good) 8%, var(--mix)); border-color: color-mix(in srgb, var(--good) 25%, transparent); border-left-color: var(--sc); }
.tr-session.done .tr-session-sport { text-decoration: line-through; color: var(--ink-soft); }
.tr-session.late { border-color: color-mix(in srgb, var(--bad) 35%, transparent); }

.tr-check {
  flex: none; width: 20px; height: 20px; border-radius: 6px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface);
  display: grid; place-items: center; padding: 0; color: #fff;
}
.tr-check:hover { border-color: var(--brand); }
.tr-check svg { width: 12px; height: 12px; }
.tr-session.done .tr-check { background: var(--good); border-color: var(--good); }
.tr-late { flex: none; color: var(--bad); font-weight: 800; font-size: .8rem; }
.tr-del { flex: none; border: none; background: transparent; color: var(--muted); font-size: .9rem; padding: 0 .15rem; border-radius: 6px; cursor: pointer; }
.tr-del:hover { color: var(--bad); }

.tr-sports { display: flex; flex-wrap: wrap; gap: .5rem; margin: .3rem 0 .2rem; }
.tr-sports .nutri-chip > button[disabled] { cursor: default; opacity: 1; }

.tr-hist { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: .5rem; }
.tr-hist-col { min-width: 0; text-align: center; }
.tr-hist-bar { height: 64px; border-radius: 7px; background: var(--surface-2); display: flex; align-items: flex-end; overflow: hidden; }
.tr-hist-bar > span { width: 100%; background: color-mix(in srgb, var(--brand) 45%, var(--mix)); transition: height .4s ease; }
.tr-hist-col.active .tr-hist-bar > span { background: var(--brand); }
.tr-hist-week { font-size: .66rem; margin-top: .4rem; color: var(--ink-soft); font-weight: 600; }
.tr-hist-val { font-size: .66rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Confort mobile / PWA ---------- */
html { -webkit-text-size-adjust: 100%; }
/* Supprime le rebond élastique iOS (le « ça sort un peu » au swipe latéral).
   Surtout PAS d'overflow-x: hidden ici : sur html/body ça casse le position: sticky
   de la sidebar (elle se colle au conteneur de défilement au lieu de l'écran). */
html, body { overscroll-behavior: none; }

@media (max-width: 960px) {
  /* Le sélecteur d'univers passe en pleine largeur, la nav reste une barre défilante */
  .mode-switch { width: 100%; }
  .nav-group { flex-direction: row; align-items: center; gap: .3rem; flex: 0 0 auto; }
  .nav-group:not([hidden]) ~ .nav-group:not([hidden]) { margin-top: 0; margin-left: .2rem; padding-left: .5rem; border-left: 1px solid var(--line); }

  /* Encoche & barre d'accueil quand le cockpit tourne en app.
     calc() et non max() : en mode app le contenu démarre SOUS la barre d'état,
     il faut donc AJOUTER l'encoche à la marge, pas prendre le plus grand des deux. */
  .app-shell { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }

  /* iOS zoome sur un champ dont la police < 16px : on force 16px */
  input, select, textarea { font-size: 16px; }

  /* Entraînements : la semaine s'empile en lignes lisibles */
  .tr-week { grid-template-columns: minmax(0, 1fr); gap: .4rem; }
  .tr-day { flex-direction: row; align-items: flex-start; gap: .7rem; padding: .55rem .7rem; }
  .tr-day-head { flex: 0 0 46px; flex-direction: column; align-items: flex-start; gap: 0; }
  .tr-day-body { flex: 1; }
  .tr-session-sport, .tr-session-note { white-space: normal; }
  .tr-add select, .tr-add #trAddNote, .tr-add .button { flex: 1 1 100%; min-width: 0; }
  .tr-hist { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem; }
  .week-nav { flex: 1 1 100%; }
  #trWeekMeta { margin-left: 0; }
}

/* ---------- Responsive ---------- */
/* ---------- Mobile / tablette ---------- */
@media (max-width: 960px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }

  /* La sidebar devient une barre supérieure collante */
  .sidebar {
    position: sticky; top: 0; z-index: 40; height: auto; min-width: 0;
    flex-direction: column; gap: .55rem;
    /* L'encoche / Dynamic Island s'ajoute ICI, dans le shorthand : une règle padding-top
       séparée placée avant serait écrasée par ce raccourci. */
    padding: calc(.7rem + env(safe-area-inset-top, 0px)) .9rem 0;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .sidebar-head { display: flex; align-items: center; justify-content: space-between; }
  .brand strong { font-size: 1rem; }
  .brand-mark svg { width: 26px; height: 26px; }

  /* Navigation horizontale défilable (chips icône + libellé) */
  nav {
    flex-direction: row; flex-wrap: nowrap; gap: .3rem; min-width: 0;
    overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
    margin: 0 -.9rem; padding: .1rem .9rem .55rem; scrollbar-width: none;
    overscroll-behavior-x: contain; /* le rebond de la barre ne déborde pas sur la page */
  }
  nav::-webkit-scrollbar { display: none; }
  .nav-item { flex: 0 0 auto; padding: .5rem .8rem; }
  .nav-item:not(.active):hover { transform: none; }
  .sidebar-footer { display: none; }

  /* Marge basse généreuse + barre d'accueil iOS : sinon le dernier élément colle au bord
     et on a l'impression de ne pas pouvoir descendre. */
  main { padding: 1.1rem 1.1rem calc(2.5rem + env(safe-area-inset-bottom, 0px)); max-width: none; }
  .topbar { margin-bottom: 1.1rem; }
  .topbar h1 { font-size: 1.5rem; }

  /* Héros : empilement propre et centré */
  .day-hero, .campaign-hero, .kpi-hero, .content-hero, .prod-hero {
    flex-direction: column; align-items: stretch; gap: 1.1rem;
  }
  .day-focus, .campaign-countdown { width: 100%; text-align: center; }
  .campaign-countdown strong { font-size: 2.4rem; }
  .kpi-month-switch { align-self: flex-start; }

  .metric-grid, .activity-grid, .kpi-ov-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Les objectifs de campagne passent en colonne sur téléphone */
  .goal-grid { grid-template-columns: minmax(0, 1fr); }
  /* « / 12 000 abonnés » en nowrap poussait la carte au-delà de l'écran */
  .goal-target { white-space: normal; }
  .objective-grid, .dashboard-grid, .niveau-two, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .panel-heading { flex-wrap: wrap; }
}

@media (max-width: 520px) {
  main { padding: .85rem .85rem calc(2.5rem + env(safe-area-inset-bottom, 0px)); }

  /* To do : sur petit écran, les étiquettes écrasaient le texte à ~35px de large,
     qui s'empilait alors un mot par ligne. On passe le texte + la croix sur la 1re ligne,
     et on renvoie rubrique + priorité sur une 2e ligne. */
  .todo-row { flex-wrap: wrap; row-gap: .45rem; gap: .5rem; }
  .todo-check { order: 1; }
  .todo-text  { order: 2; flex: 1 1 auto; min-width: 0; }
  .todo-del   { order: 3; }
  .todo-row::after { content: ""; flex-basis: 100%; height: 0; order: 4; } /* force le saut de ligne */
  .todo-tag   { order: 5; margin-left: calc(20px + .5rem); }
  .todo-prio  { order: 6; }
  .panel { padding: 1.05rem; }
  .topbar-xp { display: none; }
  .topbar h1 { font-size: 1.35rem; }

  .metric-grid, .activity-grid, .kpi-summary, .kpi-ov-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Doit rester APRÈS la règle .metric-grid ci-dessus : même spécificité, c'est l'ordre qui départage. */
  .goal-grid { grid-template-columns: minmax(0, 1fr); }
  .day-timer { font-size: 3rem; }

  /* Nav compacte mais avec libellés conservés */
  .nav-item { font-size: .82rem; padding: .45rem .7rem; gap: .5rem; }
  .nav-ico { width: 17px; height: 17px; }

  /* Formulaires qui empilent proprement */
  .todo-add { flex-direction: column; align-items: stretch; }
  .todo-add select, .todo-add .button, .todo-add input { width: 100%; min-width: 0; }
  .focus-set { justify-content: center; }
  .prod-form .prod-screen-total { grid-template-columns: 1fr 1fr; }

  /* En-têtes de panneau : titre + action sur 2 lignes si besoin */
  .panel-heading .button, .panel-head-actions { margin-top: .2rem; }
}

/* ============================================================
   Premium polish — halos de lumière & micro-interactions
   (couche ajoutée par-dessus la DA, volontairement très légère)
   ============================================================ */
:root {
  --edge: inset 0 1px 0 rgba(255,255,255,.6);          /* liseré lumineux en haut des cartes */
  --glow: color-mix(in srgb, var(--brand) 30%, transparent);
  --lift: 0 12px 30px color-mix(in srgb, #1a1a40 9%, transparent);
}
html[data-theme="dark"] {
  --edge: inset 0 1px 0 rgba(255,255,255,.06);
  --glow: color-mix(in srgb, var(--brand) 55%, transparent);
  --lift: 0 14px 34px rgba(0,0,0,.55);
}

/* Transitions douces (thème, survols) */
body, .sidebar, .panel, .nav-item, .button, input, select, textarea,
.content-card, .todo-row, .metric-card, .kpi-stat, .goal-card, .activity-cell,
.prod-hist-row, .quest-bar, .kpi-card, .theme-toggle, .kebab-button, .ct-chip {
  transition: background-color .25s ease, border-color .2s ease, color .2s ease,
              box-shadow .22s ease, transform .16s ease;
}

/* Sélection de texte teintée */
::selection { background: color-mix(in srgb, var(--brand) 24%, transparent); }

/* Focus clavier soigné */
button:focus-visible, .nav-item:focus-visible, .subtab:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent);
}

/* Cartes : fin liseré de lumière en haut */
.panel, .quest-bar { box-shadow: var(--shadow), var(--edge); }

/* Cartes interactives : léger soulèvement + halo au survol */
.metric-card:hover, .kpi-stat:hover, .content-card:hover, .goal-card:hover,
.activity-cell:hover, .prod-hist-row:hover, .kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow), var(--edge), var(--lift);
}

/* Héros sombres : halo de lumière indigo très léger (haut-droite) */
.day-hero, .campaign-hero, .kpi-hero, .prod-hero {
  background:
    radial-gradient(135% 160% at 88% -35%, var(--glow), transparent 55%),
    linear-gradient(135deg, var(--hero-1), var(--hero-2));
}
/* Léger reflet sur la bannière saison */
.season-banner {
  background:
    radial-gradient(120% 180% at 92% -40%, rgba(255,255,255,.22), transparent 55%),
    linear-gradient(135deg, #4f46e5, #6366f1);
}

/* Navigation active : halo doux */
.nav-item.active {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 22%, transparent),
              0 4px 14px color-mix(in srgb, var(--brand) 16%, transparent);
}
.nav-item:not(.active):hover { transform: translateX(2px); }

/* Bouton primaire : reflet interne + halo qui respire au survol */
.button.primary {
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 30%, transparent),
              inset 0 1px 0 rgba(255,255,255,.22);
}
.button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 9px 24px color-mix(in srgb, var(--brand) 42%, transparent),
              inset 0 1px 0 rgba(255,255,255,.22);
}
.button:active { transform: translateY(1px); }

/* Toggle thème & kebab : réaction subtile */
.theme-toggle:hover { transform: translateY(-1px); box-shadow: var(--shadow); }


/* Timer focus : léger glow du chiffre */
.day-timer { text-shadow: 0 0 24px rgba(255,255,255,.18); }

/* Barres de progression : reflet */
.progress-track span, .xp-mini-track span, .rank-progress span, .goal-bar span, .kr-bar span {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}

/* Modales : entrée en douceur */
dialog[open] { animation: dlgIn .22s cubic-bezier(.22,1,.36,1); }
@keyframes dlgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* Scrollbars fines et discrètes */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink) 22%, transparent) transparent; }
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--ink) 18%, transparent);
  border-radius: 99px; border: 3px solid transparent; background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--ink) 32%, transparent); background-clip: padding-box; }

/* Respecte les préférences de réduction de mouvement */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   En-têtes (héros) adaptés au thème
   Clair : bandeau lumineux teinté indigo · Sombre : charbon + halo
   ============================================================ */
:root {
  --hero-bg: radial-gradient(130% 150% at 88% -30%, color-mix(in srgb, var(--brand) 13%, transparent), transparent 55%),
             linear-gradient(150deg, #ffffff 0%, #eef0fb 100%);
  --hero-fg: #1a1a24;
  --hero-fg-soft: #5c5c6b;
  --hero-line: var(--line);
  --hero-ctl: #ffffff;
  --hero-ctl-bd: var(--line);
  --hero-ctl-hover: #f2f2f7;
}
html[data-theme="dark"] {
  --hero-bg: radial-gradient(135% 160% at 88% -35%, var(--glow), transparent 55%),
             linear-gradient(135deg, var(--hero-1), var(--hero-2));
  --hero-fg: #f4f4f6;
  --hero-fg-soft: rgba(255,255,255,.72);
  --hero-line: rgba(255,255,255,.10);
  --hero-ctl: rgba(255,255,255,.12);
  --hero-ctl-bd: rgba(255,255,255,.22);
  --hero-ctl-hover: rgba(255,255,255,.2);
}

.day-hero, .campaign-hero, .kpi-hero, .prod-hero {
  background: var(--hero-bg);
  color: var(--hero-fg);
  border: 1px solid var(--hero-line);
}
.day-hero .eyebrow, .campaign-hero .eyebrow, .kpi-hero .eyebrow, .prod-hero .eyebrow { color: var(--hero-fg-soft); }
.day-hero-summary,
.day-hero .muted, .campaign-hero .muted, .kpi-hero .muted, .prod-hero .muted { color: var(--hero-fg-soft); }
.day-timer { color: var(--hero-fg); text-shadow: none; }
html[data-theme="dark"] .day-timer { text-shadow: 0 0 24px rgba(255,255,255,.15); }
.campaign-countdown span { color: var(--hero-fg-soft); }

/* Contrôles posés sur un héros (focus, mois KPI) */
.button.light { background: var(--hero-ctl); color: var(--hero-fg); border-color: var(--hero-ctl-bd); }
.button.light:hover { background: var(--hero-ctl-hover); }
.button.day-reset { background: transparent; color: var(--hero-fg-soft); border-color: var(--hero-ctl-bd); }
.focus-step { background: var(--hero-ctl); color: var(--hero-fg); border-color: var(--hero-ctl-bd); }
.focus-step:hover { background: var(--hero-ctl-hover); }
.focus-min { background: var(--hero-ctl); color: var(--hero-fg); border-color: var(--hero-ctl-bd); }
.focus-unit { color: var(--hero-fg-soft); }
.kpi-month-switch { background: var(--hero-ctl); border: 1px solid var(--hero-ctl-bd); }
.kpi-month-btn { color: var(--hero-fg-soft); }
.kpi-month-btn.active { background: var(--brand); color: #fff; box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 35%, transparent); }

/* Selecteur de cockpit (menu sous le logo) */
.brand { position: relative; cursor: pointer; user-select: none; }
.brand-caret { font-size: 10px; opacity: .55; }
.brand-menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 180px; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 14px 36px rgba(13, 19, 31, .22); padding: 6px; z-index: 300; }
.brand-menu[hidden] { display: none; }
.brand-menu a { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; color: #1e293b; text-decoration: none; }
.brand-menu a:hover { background: #f1f5f9; }
.brand-menu a.active { background: #eef2ff; color: #4f46e5; }

/* ==========================================================================
   Mobile : défilement interne façon app native.
   Le document lui-même ne défile plus (donc iOS n'a plus AUCUN rebond global à
   animer) ; c'est <main> qui défile, et son propre rebond reste contenu dans
   l'app, sur le fond de page — continu, fluide.
   Bloc placé en FIN de fichier : il doit gagner la cascade sur les règles mobiles.
   ========================================================================== */
@media (max-width: 960px) {
  html, body { height: 100%; overflow: hidden; }
  .app-shell {
    height: 100vh; height: 100dvh;
    min-height: 0;
    display: grid; grid-template-rows: auto minmax(0, 1fr);
  }
  .sidebar { position: static; height: auto; }
  main {
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
}

/* ==========================================================================
   Écrans tactiles : pas d'état « survol ».
   Sur iOS, :hover se déclenche au toucher et RESTE collé jusqu'au tap suivant :
   une rubrique semblait « à moitié sélectionnée » en gris. On neutralise aussi
   le voile gris natif d'iOS sur les éléments tapés. Ne change rien à la souris.
   ========================================================================== */
@media (hover: none) {
  * { -webkit-tap-highlight-color: transparent; }

  .nav-item:not(.active):hover { background: transparent; color: var(--ink-soft); transform: none; }
  .mode-btn:not(.active):hover { background: transparent; color: var(--ink-soft); }
  .subtab:not(.active):hover { background: transparent; color: var(--ink-soft); }
  .kebab-button:hover { background: transparent; color: var(--ink-soft); }
  .icon-button:hover { background: var(--surface-2); }
  .button.secondary:hover { background: var(--surface); }
  .stepper-btn:hover { background: var(--surface-2); border-color: var(--line); }
  .tr-day:hover { border-color: var(--line); }
  .tr-day.today:hover { border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
  .tr-empty:hover { color: var(--muted); }
  .trm-chip:hover { background: var(--surface-2); color: var(--ink); }
  .nutri-chip > button:hover { color: var(--ink); }
  .prod-hist-row:hover { background: var(--surface); }
  .todo-tag:hover { filter: none; }
  .habit-cell:hover { filter: none; }
}
/* ==========================================================================
   Habitudes façon tableur : plage sélectionnée + poignée de recopie
   ========================================================================== */
.kpi-table-wrap { position: relative; }
.habit-cell { user-select: none; -webkit-user-select: none; }
.habit-table .habit-cell.hsel {
  outline: 2px solid var(--brand); outline-offset: -2px;
  box-shadow: inset 0 0 0 99px color-mix(in srgb, var(--brand) 16%, transparent);
}
.habit-table th[data-hrow] { cursor: pointer; }
.habit-table th[data-hrow]:hover { color: var(--brand); }
#habitFill {
  position: absolute; z-index: 6; width: 12px; height: 12px; border-radius: 50%;
  background: var(--brand); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
  cursor: crosshair; touch-action: none;
}
/* zone de prise élargie, surtout pour le doigt */
#habitFill::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; }
/* ---------- Video YouTube quotidienne ---------- */
.yt-cards { margin-bottom: 0; }
.yt-list { display: flex; flex-direction: column; gap: .6rem; }
.yt-item {
  display: flex; align-items: center; gap: .8rem; min-width: 0;
  padding: .8rem .9rem; border-radius: 12px;
  border: 1px solid var(--line); border-left: 3px solid var(--muted); background: var(--surface);
}
.yt-item-main { flex: 1; min-width: 0; }
.yt-item-title { font-weight: 650; font-size: .9rem; overflow-wrap: anywhere; }
.yt-item-meta { font-size: .76rem; color: var(--muted); margin-top: .15rem; }
.yt-item.yt-wait { border-left-color: var(--muted); }
.yt-item.yt-up { border-left-color: var(--brand); background: color-mix(in srgb, var(--brand) 4%, var(--mix)); }
.yt-item.yt-ok { border-left-color: var(--good); background: color-mix(in srgb, var(--good) 6%, var(--mix)); }
.yt-item.yt-err { border-left-color: var(--bad); background: color-mix(in srgb, var(--bad) 5%, var(--mix)); }
.yt-bar { height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: .4rem; }
.yt-bar.big { height: 8px; margin-top: .2rem; }
.yt-bar > span { display: block; height: 100%; border-radius: 3px; background: var(--brand); transition: width .3s ease; }
.yt-link { flex: none; font-size: .8rem; font-weight: 650; color: var(--brand); text-decoration: none; white-space: nowrap; }
.yt-link:hover { text-decoration: underline; }
.yt-retry { flex: none; font-size: .78rem; padding: .35rem .7rem; }
#ytConnect { text-decoration: none; display: inline-flex; align-items: center; align-self: flex-start; }
#ytStatus { margin: 0; font-size: .82rem; }
/* ---------- Habitudes : poignée de déplacement + alignement des en-têtes ---------- */
#habitTable thead tr:first-child th { vertical-align: top; text-align: center; padding-top: 18px; }
.habit-grip { position: absolute; top: 3px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: .85em; line-height: 1; cursor: grab; touch-action: none; user-select: none; opacity: .5; }
.habit-grip:hover { opacity: 1; color: var(--brand); }
.habit-name { display: block; text-align: center; }
.habit-del { position: absolute; top: 2px; right: 2px; margin: 0; }
.habit-col-h.col-drag-src { opacity: .35; }
#habitTable.col-dragging { cursor: grabbing; user-select: none; }
#habitTable.col-dragging .habit-grip { cursor: grabbing; }
.habit-col-h.col-drop-before::before, .habit-col-h.col-drop-after::after { content: ''; position: absolute; top: 2px; bottom: 2px; width: 3px; background: var(--brand); border-radius: 2px; z-index: 5; }
.habit-col-h.col-drop-before::before { left: -1px; }
.habit-col-h.col-drop-after::after { right: -1px; }
@media (hover: none) { .habit-grip { opacity: .8; font-size: .95em; top: 2px; } }
/* ---------- KPI : fenêtre défilante + en-tête de colonnes figé ---------- */
.kpi-scroll { max-height: min(66vh, 520px); overflow-y: auto; }
.kpi-scroll #kpiTable .kpi-col-row th { position: sticky; top: 0; z-index: 4; background: var(--surface); }
.kpi-scroll #kpiTable .kpi-col-row .kpi-day-h { z-index: 6; background: var(--surface-2); }
.kpi-scroll #kpiTable tr.kpi-today-row .kpi-day { color: var(--brand-ink); font-weight: 800; }
.kpi-scroll #kpiTable tr.kpi-today-row .kpi-input { background: var(--brand-soft); }
/* ---------- Habitudes : fenêtre défilante + en-tête figé ---------- */
.habit-scroll { max-height: min(66vh, 520px); overflow-y: auto; }
.habit-scroll #habitTable thead tr:first-child th { position: sticky; top: 0; z-index: 4; }
.habit-scroll #habitTable thead tr:first-child .kpi-day-h { z-index: 6; }
.habit-scroll #habitTable tr.habit-today-row .kpi-day { color: var(--brand-ink); font-weight: 800; }
/* ---------- Productivité : carte capture d'écran (IA vision) ---------- */
.prod-shot-card { border: 1px solid var(--brand-soft); }
.prod-shot { display: flex; flex-direction: column; gap: .7rem; }
.prod-shot-thumbs { display: flex; flex-wrap: wrap; gap: .5rem; }
.prod-shot-thumbs:empty { display: none; }
.prod-shot-thumb { position: relative; width: 76px; height: 76px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.prod-shot-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.prod-shot-del { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; padding: 0; border: none; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.prod-shot-del:hover { background: var(--bad); }
/* ---------- Contenu : pastilles du planning hebdomadaire ---------- */
.ct-pastille {
  display: flex; flex-direction: column; gap: .15rem; min-width: 0;
  padding: .35rem .45rem; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); border-left: 3px solid var(--sc);
  background: var(--surface); -webkit-tap-highlight-color: transparent;
}
.ct-pastille:hover { border-color: color-mix(in srgb, var(--sc) 45%, var(--line)); }
.ct-pastille.overdue { border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.ct-pastille.posted { opacity: .6; }
.ct-pastille.posted .ct-pastille-title { text-decoration: line-through; }
.ct-pastille-title { font-size: .74rem; font-weight: 650; line-height: 1.2; white-space: normal; overflow-wrap: break-word; hyphens: auto; color: var(--ink); }
.ct-pastille-status { display: inline-flex; align-items: center; gap: .25rem; font-size: .63rem; color: var(--muted); }
.ct-pastille-status .ct-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
/* ---------- Nutrition : bouton micro (dictée) ---------- */
#nutriMic .nutri-mic-label { display: inline; }
#nutriMic.recording { background: var(--bad); color: #fff; border-color: var(--bad); animation: nutriPulse 1.2s ease-in-out infinite; }
#nutriMic.recording svg { stroke: #fff; }
@keyframes nutriPulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 40%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }