/* ==========================================================================
   Habitudes — feuille de style
   Thème sombre = les couleurs du Google Sheet (bleu nuit, vert menthe, une
   couleur par semaine). Thème clair = la même identité sur fond blanc.
   Police système (San Francisco sur iPhone) : rien à télécharger.
   ========================================================================== */

/* --- Couleurs ------------------------------------------------------------ */
/* Sombre : palette du Sheet (BG_DARK, BG_PANEL, BG_PANEL_ALT, ACCENT, SEP_COLOR) */
:root {
  --bg: #1A1E3F;          /* fond général (BG_DARK) */
  --panel: #242963;       /* blocs (BG_PANEL) */
  --panel-2: #2D3375;     /* champs, lignes alternées (BG_PANEL_ALT) */
  --line: #3A3F7A;        /* séparateurs (SEP_COLOR) */
  --ink: #FFFFFF;
  --muted: #A9AEDA;
  --faint: #6E73AC;
  --accent: #00E5B0;      /* vert menthe (ACCENT) */
  --accent-ink: #00E5B0;  /* accent utilisé pour du texte */
  --on-accent: #10142F;   /* texte posé sur l'accent */
  --accent-soft: rgba(0, 229, 176, .16);
  --track: rgba(255, 255, 255, .09); /* fond des anneaux et des barres */
  --up: #00E5B0; --down: #FF7675; --bad: #FF7675;
  /* Une couleur par semaine, comme les en-têtes SEMAINE 1 → 6 du Sheet */
  --w1: #E84393; --w2: #6C5CE7; --w3: #0984E3; --w4: #FDCB6E; --w5: #00B894; --w6: #FF7675;
  --streak: #FDCB6E;
  --card-shadow: none;
  --shadow: 0 12px 34px rgba(6, 8, 30, .5);
  --band: #1A1E3F;        /* bande sous l'heure et la batterie (iPhone) */
  --radius: 18px;
  --tabbar-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
/* Clair : fond blanc cassé, encre bleu nuit, mêmes couleurs de semaines */
:root[data-theme="light"] {
  --bg: #F3F4F9; --panel: #FFFFFF; --panel-2: #EEF0F7; --line: #E3E5EF;
  --ink: #1A1E3F; --muted: #646890; --faint: #A3A6C2;
  --accent: #00C49A; --accent-ink: #00876A; --on-accent: #10142F; --accent-soft: rgba(0, 196, 154, .13);
  --track: #E8EAF3; --up: #00876A; --down: #D9434A; --bad: #D9434A;
  --w1: #E84393; --w2: #6C5CE7; --w3: #0984E3; --w4: #F0AE1E; --w5: #00B894; --w6: #FF6B6B; --streak: #B87700;
  --card-shadow: 0 1px 2px rgba(26, 30, 63, .05), 0 4px 16px rgba(26, 30, 63, .05);
  --shadow: 0 12px 34px rgba(26, 30, 63, .16);
  --band: #1A1E3F;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #F3F4F9; --panel: #FFFFFF; --panel-2: #EEF0F7; --line: #E3E5EF;
    --ink: #1A1E3F; --muted: #646890; --faint: #A3A6C2;
    --accent: #00C49A; --accent-ink: #00876A; --on-accent: #10142F; --accent-soft: rgba(0, 196, 154, .13);
    --track: #E8EAF3; --up: #00876A; --down: #D9434A; --bad: #D9434A;
    --w1: #E84393; --w2: #6C5CE7; --w3: #0984E3; --w4: #F0AE1E; --w5: #00B894; --w6: #FF6B6B; --streak: #B87700;
    --card-shadow: 0 1px 2px rgba(26, 30, 63, .05), 0 4px 16px rgba(26, 30, 63, .05);
    --shadow: 0 12px 34px rgba(26, 30, 63, .16);
    --band: #1A1E3F;
    color-scheme: light;
  }
}

/* --- Base ---------------------------------------------------------------- */
/* touch-action: manipulation = pas de zoom quand on touche deux fois vite
   (on peut toujours zoomer en écartant deux doigts) */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* Ce qu'on touche souvent ne se sélectionne pas comme du texte (pas de loupe ni de menu) */
.habit, .cell, .wd, .row, .nav-btn, .chip, .btn, .seg button, .tabbar a, .g-edit, .b-name {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
svg { display: block; }

.view {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 32px);
  min-height: 100vh;
}
body[data-view="month"] .view, body[data-view="year"] .view { max-width: 1440px; }

/* --- En-tête des écrans -------------------------------------------------- */
.page-head { margin: 6px 0 14px; }
.eyebrow {
  font-size: 11.5px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent-ink); margin-bottom: 2px;
}
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.head-titles { min-width: 0; }
.page-title { font-size: 32px; line-height: 1.1; font-weight: 800; letter-spacing: -0.03em; margin: 0; }
.page-sub { color: var(--muted); margin: 3px 0 0; font-size: 15px; }
.head-nav { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.nav-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel); color: var(--ink); box-shadow: var(--card-shadow);
}
.nav-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn[aria-disabled="true"] { opacity: .3; pointer-events: none; }
.nav-btn:active { opacity: .7; }
.chip-link {
  height: 32px; padding: 0 12px; border-radius: 999px; display: inline-flex; align-items: center;
  font-size: 13.5px; font-weight: 650; color: var(--accent-ink); background: var(--accent-soft);
}

/* --- Cartes -------------------------------------------------------------- */
.card {
  background: var(--panel); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--card-shadow); min-width: 0;
}
.card + .card { margin-top: 12px; }
.card-title {
  font-size: 12px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink); margin: 0 0 12px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head .card-title { margin: 0; }
.card-note { font-size: 12.5px; color: var(--muted); }
.card-foot { font-size: 13px; color: var(--muted); margin: 12px 0 0; line-height: 1.45; }
.card-foot b { color: var(--ink); }

/* --- Bande de la semaine (écran Aujourd'hui) ----------------------------- */
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 4px 0 14px; }
.wd {
  display: grid; justify-items: center; gap: 4px; padding: 7px 0 8px; border-radius: 14px;
  color: var(--muted); transition: background .15s;
}
.wd-l { font-size: 11.5px; font-weight: 650; }
.wd-ring { position: relative; width: 38px; height: 38px; }
.wd-ring b {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13.5px; font-weight: 700; color: var(--ink);
}
.wd.sel { background: var(--panel); box-shadow: var(--card-shadow); }
.wd.sel .wd-l { color: var(--ink); }
.wd.is-today .wd-ring b { color: var(--accent-ink); }
.wd.future { opacity: .35; pointer-events: none; }

/* Anneaux (donut du Sheet) */
.ring-track { fill: none; stroke: var(--track); }
.ring-arc { fill: none; stroke-linecap: round; transition: stroke-dashoffset .45s cubic-bezier(.3, .8, .3, 1); }
@media (prefers-reduced-motion: reduce) { .ring-arc { transition: none; } }

/* --- Résumé du jour ------------------------------------------------------ */
.day-summary { display: flex; align-items: center; gap: 18px; padding: 18px; }
.sum-ring { position: relative; width: 96px; height: 96px; flex-shrink: 0; }
.sum-ring > b {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 22px; font-weight: 800; letter-spacing: -0.02em;
}
.sum-text { display: grid; gap: 2px; min-width: 0; }
.sum-text b { font-size: 19px; font-weight: 750; letter-spacing: -0.01em; }
.sum-text span { color: var(--muted); font-size: 15px; }
.sum-text small { color: var(--muted); font-size: 13px; margin-top: 6px; }
.day-summary.perfect .sum-text span { color: var(--accent-ink); font-weight: 650; }

/* --- Liste des habitudes du jour ----------------------------------------- */
.habit-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.habit {
  position: relative; width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 15px 16px 17px; border: 0; border-radius: 16px; text-align: left; cursor: pointer;
  background: var(--panel); box-shadow: var(--card-shadow); overflow: hidden;
  transition: background .2s, transform .12s;
}
.habit:active { transform: scale(.985); }
.habit-check {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  box-shadow: inset 0 0 0 2px var(--faint); color: transparent;
  transition: background .2s, box-shadow .2s, color .2s, transform .2s;
}
.habit-check svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.habit[aria-pressed="true"] .habit-check { background: var(--accent); box-shadow: none; color: var(--on-accent); transform: scale(1.06); }
.habit[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 9%, var(--panel)); }
.habit-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.habit-name { font-size: 17px; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.habit-sub { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13.5px; color: var(--muted); }
.streak { display: inline-flex; align-items: center; gap: 3px; color: var(--streak); font-weight: 650; }
.streak svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.habit-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--track); }
.habit-progress i { display: block; height: 100%; background: var(--accent); border-radius: 0 3px 3px 0; transition: width .4s ease; }

.add-link {
  display: inline-flex; align-items: center; gap: 8px; margin: 16px auto 0; padding: 10px 14px;
  border: 0; background: none; color: var(--accent-ink); font-weight: 650; cursor: pointer; border-radius: 12px;
}
.screen-today .add-link { display: flex; }
.add-link.inline { margin: 4px 0 0; padding: 8px 0; }
.add-link svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; }

/* --- Chiffres clés (bandeau du Sheet) ------------------------------------ */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi {
  background: var(--panel); border-radius: var(--radius); padding: 14px 14px 13px; box-shadow: var(--card-shadow);
  display: grid; gap: 3px; min-width: 0;
}
.kpi-label { font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kpi-val { font-size: 28px; line-height: 1.1; font-weight: 800; letter-spacing: -0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-val.accent { color: var(--accent-ink); }
.kpi-val.up { color: var(--up); }
.kpi-val.down { color: var(--down); }
.kpi-sub { font-size: 12.5px; color: var(--muted); }

/* --- Disposition de l'écran Mois ----------------------------------------- */
.mlayout, .ylayout { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.mlayout > .card + .card, .ylayout > .card + .card { margin-top: 0; }

/* Courbe */
.chart { min-height: 150px; }
.linechart { overflow: visible; }
.lc-grid { stroke: var(--line); stroke-width: 1; }
.lc-ylab, .lc-xlab { fill: var(--muted); font-size: 11px; font-weight: 500; }
.lc-line { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.lc-dot { fill: var(--accent); }
.lc-dot.today { stroke: var(--panel); stroke-width: 2.5; }
.lc-empty { fill: var(--muted); font-size: 13px; }

/* Donut */
.donut-wrap { display: flex; align-items: center; justify-content: center; gap: 22px; flex-wrap: wrap; }
.donut { position: relative; width: 148px; height: 148px; }
.donut .ring-track { stroke: var(--accent-soft); }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center b { font-size: 25px; font-weight: 800; letter-spacing: -0.03em; color: var(--accent-ink); }
.donut-center span { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 14px; }
.legend li { display: grid; grid-template-columns: 12px auto; column-gap: 8px; align-items: center; }
.legend li i { width: 12px; height: 12px; border-radius: 4px; }
.legend li b { grid-column: 2; font-size: 18px; font-weight: 750; }
.legend li span { color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.dot-accent { background: var(--accent); }
.dot-soft { background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }

/* Vue hebdomadaire : barres par jour, couleur de la semaine */
.wbars { display: flex; align-items: flex-end; gap: 2px; height: 128px; padding-bottom: 2px; border-bottom: 1px solid var(--line); }
.wb { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; border-radius: 4px 4px 0 0; }
.wb i { display: block; width: 100%; background: var(--c); border-radius: 3px 3px 1px 1px; transition: height .35s ease; }
.wb.future { align-items: flex-end; }
.wb.future::after { content: ""; display: block; width: 100%; height: 3px; border-radius: 2px; background: var(--track); }
.wb:active { opacity: .7; }
.wbars-axis { display: flex; gap: 2px; margin-top: 6px; }
.wbars-axis span {
  min-width: 0; text-align: center; font-size: 11px; font-weight: 750; color: var(--c);
  border-top: 3px solid var(--c); padding-top: 3px; margin: 0 1px;
}
.wlist { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 12px; }
.w-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 10px; margin-bottom: 6px; }
.wtag { font-size: 12px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--c); }
.wdates { font-size: 13px; color: var(--muted); flex: 1; }
.wval { font-size: 13px; color: var(--muted); white-space: nowrap; }
.wval b { color: var(--ink); font-size: 15px; }
.wval em { font-style: normal; font-weight: 700; color: var(--ink); margin-left: 8px; }

/* Barres de progression horizontales */
.pbar { display: block; height: 7px; border-radius: 4px; background: var(--track); overflow: hidden; }
.pbar i { display: block; height: 100%; border-radius: 4px; transition: width .35s ease; }

/* Top 5 */
.top { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.top li { display: flex; align-items: center; gap: 12px; }
.rank {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 8px; display: grid; place-items: center;
  font-size: 13px; font-weight: 800; background: var(--panel-2); color: var(--muted);
}
.top li:first-child .rank { background: var(--accent); color: var(--on-accent); }
.top-main { flex: 1; min-width: 0; display: grid; gap: 5px; }
.top-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-pct { font-weight: 750; font-size: 15px; min-width: 48px; text-align: right; }

/* Grille des cases (habitudes × jours) */
.grid-scroll {
  overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain; scrollbar-width: thin;
}
.hgrid, .ytable { border-collapse: separate; border-spacing: 0; }
.hgrid th, .hgrid td { padding: 0; text-align: center; }
.g-name {
  position: sticky; left: -16px; z-index: 2; background: var(--panel); text-align: left !important;
  min-width: 128px; max-width: 150px; padding: 0 10px 0 0 !important;
}
.g-name::after { /* fondu à droite de la colonne figée */
  content: ""; position: absolute; top: 0; bottom: 0; right: -10px; width: 10px;
  background: linear-gradient(90deg, var(--panel), transparent); pointer-events: none;
}
.g-weeks th { padding-bottom: 6px !important; }
.g-weeks th span {
  display: block; margin: 0 2px; padding-bottom: 4px; border-bottom: 3px solid var(--c);
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--c); white-space: nowrap;
}
.g-days th { padding-bottom: 6px !important; vertical-align: bottom; }
.g-days .g-name { display: table-cell; font-size: 11px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.g-days .g-name span:first-child { margin-right: 6px; }
.g-day { display: grid; justify-items: center; width: 30px; margin: 0 auto; padding: 3px 0; border-radius: 9px; }
.g-day span { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.g-day b { font-size: 12.5px; font-weight: 700; }
th.today .g-day { background: var(--accent); }
th.today .g-day span, th.today .g-day b { color: var(--on-accent); }
.g-edit {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; min-height: 34px;
  border: 0; background: none; padding: 0; text-align: left; cursor: pointer;
}
.g-hname { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-goal { font-size: 12px; color: var(--muted); font-weight: 650; flex-shrink: 0; }
.hgrid td { height: 34px; }
.hgrid td.ws, .hgrid th.ws { padding-left: 5px; }
.cell {
  width: 26px; height: 26px; margin: 0 2px; border: 0; border-radius: 8px; display: grid; place-items: center; cursor: pointer;
  background: var(--panel-2); color: transparent; box-shadow: inset 0 0 0 1.5px var(--line);
  transition: background .15s, box-shadow .15s;
}
.cell svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.cell[aria-pressed="true"] { background: var(--c); box-shadow: none; color: #fff; }
.cell:disabled { opacity: .35; cursor: default; }
.cell.off { background: none; box-shadow: none; position: relative; }
.cell.off::after { content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 2px; translate: -50% -50%; border-radius: 1px; background: var(--line); }
td.today .cell:not(:disabled) { box-shadow: inset 0 0 0 2px var(--accent); }
td.today .cell[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent); }

/* Bilan par habitude */
.bilan { display: grid; gap: 14px; }
.b-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.b-name { border: 0; background: none; padding: 0; text-align: left; font-weight: 650; font-size: 15px; cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-val { font-size: 13px; color: var(--muted); white-space: nowrap; }
.b-val b { font-size: 16px; color: var(--ink); }
.b-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.b-meta b { color: var(--ink); font-weight: 700; }

/* --- Écran Année --------------------------------------------------------- */
.ybars { display: flex; align-items: stretch; gap: 5px; height: 190px; }
.yb { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.yb-val { font-size: 10.5px; font-weight: 700; min-height: 14px; white-space: nowrap; color: var(--ink); }
.yb-track { flex: 1; width: 100%; max-width: 38px; display: flex; align-items: flex-end; border-radius: 7px; background: var(--track); overflow: hidden; }
.yb-track i { display: block; width: 100%; background: var(--c); border-radius: 7px 7px 0 0; }
.yb-lab { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: capitalize; }
.yb.current .yb-lab { color: var(--accent-ink); font-weight: 800; }
.yb.untracked .yb-track { background: repeating-linear-gradient(-45deg, transparent 0 5px, var(--track) 5px 7px); }
.yb:active { opacity: .7; }
.ytable th, .ytable td { padding: 4px 3px; text-align: center; }
.ytable thead th { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: capitalize; padding-bottom: 8px; }
.ytable thead th.today { color: var(--accent-ink); }
.ytable .g-name { font-weight: 600; }
.ytable thead .g-name { text-transform: uppercase; letter-spacing: .07em; font-weight: 750; }
.y-total b { font-size: 15px; }
.ytable td.y-total { padding-right: 10px; }
.heat {
  display: grid; place-items: center; width: 38px; height: 32px; border-radius: 9px; font-size: 13px; font-weight: 700;
  background: color-mix(in srgb, var(--accent) calc(var(--a) * 85%), var(--panel-2)); color: var(--ink);
}
.heat.none { background: none; color: var(--faint); }

/* --- Réglages ------------------------------------------------------------ */
.section-title { font-size: 13px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin: 28px 0 8px; }
.section-title.split { display: flex; justify-content: space-between; align-items: center; }
.section-title.split h2 { font: inherit; margin: 0; }
.list-card { padding: 4px 16px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 10px 0; cursor: pointer; color: inherit; }
.row + .row { border-top: 1px solid var(--line); }
.row:active { opacity: .65; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title.muted-title { color: var(--muted); }
.row-sub { color: var(--muted); font-size: 13.5px; }
.row-empty { padding: 14px 0; margin: 0; }
.chev { color: var(--faint); }
.chev svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
/* Liste des habitudes réordonnable (voir js/sortable.js) */
.sortable-row { position: relative; background: var(--panel); transition: background .2s .12s; }
.sortable-row:active { opacity: 1; }
.sortable-row.press { background: var(--panel-2); }
.sorting .sortable-row { transition: transform .2s ease; }
.sortable-row.dragging {
  z-index: 5; transition: none; background: var(--panel-2); border-top-color: transparent;
  margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 14px; box-shadow: var(--shadow);
}
.sortable-row.dragging + .row { border-top-color: transparent; }
.grip {
  width: 42px; height: 42px; margin-right: -10px; flex-shrink: 0; border: 0; background: none; border-radius: 12px;
  display: grid; place-items: center; color: var(--faint); cursor: grab; touch-action: none;
}
.grip svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }
.dragging .grip { color: var(--accent-ink); cursor: grabbing; }
body.sorting { -webkit-user-select: none; user-select: none; cursor: grabbing; }
.danger-text { color: var(--bad); }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; line-height: 1.45; }

/* Choix à plusieurs options (thème) */
.seg { display: flex; background: var(--panel); border-radius: 14px; padding: 4px; gap: 3px; box-shadow: var(--card-shadow); }
.seg button {
  flex: 1; min-height: 40px; border: 0; background: none; border-radius: 11px; cursor: pointer;
  font-weight: 650; font-size: 15px; color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* --- Boutons, champs ----------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 52px; padding: 0 20px; border-radius: 14px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 17px;
}
.btn:active { opacity: .8; }
.btn:disabled { opacity: .45; }
.btn.secondary { background: var(--panel-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--line); }
.link-btn { background: none; border: 0; color: var(--accent-ink); font-weight: 650; padding: 10px 0; cursor: pointer; }
.link-btn.small { font-size: 13px; letter-spacing: 0; text-transform: none; padding: 4px 0; }
.stack > * + * { margin-top: 10px; }
.field { display: block; margin-bottom: 18px; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
.input {
  width: 100%; min-height: 50px; padding: 0 14px; border-radius: 13px; font-size: 17px;
  border: 1.5px solid transparent; background: var(--panel-2); color: var(--ink);
}
.input:focus { border-color: var(--accent); outline: none; }
.input[type="date"] { -webkit-appearance: none; appearance: none; display: flex; align-items: center; }
.mt-sm { margin-top: 10px; }
.stepper { display: flex; align-items: center; background: var(--panel-2); border-radius: 14px; overflow: hidden; }
.stepper button { width: 58px; height: 52px; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--ink); }
.stepper input { flex: 1; min-width: 0; text-align: right; border: 0; background: none; font-size: 22px; font-weight: 750; height: 52px; padding: 0 6px; }
.stepper input:focus { outline: none; }
.stepper .unit { flex: 1; color: var(--muted); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 38px; padding: 0 15px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--panel-2); font-size: 15px; font-weight: 600; color: var(--ink);
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* --- Fenêtre du bas ------------------------------------------------------ */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(5, 7, 25, .55); z-index: 40; animation: fade .2s; touch-action: none; }
html.sheet-open { overscroll-behavior: none; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 600px; margin: 0 auto;
  max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: var(--panel); border-radius: 24px 24px 0 0; padding: 10px 20px calc(var(--safe-bottom) + 22px);
  animation: rise .3s cubic-bezier(.2, .9, .3, 1); box-shadow: var(--shadow);
}
.sheet::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 16px; }
.sheet h2 { font-size: 21px; margin: 0 0 18px; letter-spacing: -0.02em; }
.sheet .input, .sheet .stepper, .sheet .chip:not([aria-pressed="true"]), .sheet .btn.secondary { background: var(--panel-2); }
.sheet-text { color: var(--muted); margin: -6px 0 20px; line-height: 1.5; font-size: 15px; }
@keyframes rise { from { translate: 0 100%; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-backdrop { animation: none; } }

/* --- Connexion ----------------------------------------------------------- */
body.auth .tabbar { display: none; }
.auth-screen { max-width: 400px; margin: 9vh auto 0; }
.auth-logo { border-radius: 20px; margin-bottom: 18px; }
.auth-screen .page-title { margin-bottom: 6px; }
.auth-screen .page-sub { margin-bottom: 24px; }
.auth-error { color: var(--bad); font-weight: 600; min-height: 1.4em; margin: 0 0 10px; }

/* --- Barre d'onglets ----------------------------------------------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding: 0 8px var(--safe-bottom);
  display: flex; justify-content: space-around; align-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent); border-top: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
}
.tabbar a { flex: 1; max-width: 140px; display: grid; justify-items: center; gap: 3px; color: var(--faint); font-size: 10.5px; font-weight: 650; padding: 6px 0; }
.tabbar a svg { width: 25px; height: 25px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--accent-ink); }
.tabbar a.active svg { stroke-width: 2.1; }

/* Bande sous l'heure et la batterie de l'iPhone (texte blanc : fond bleu nuit) */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: var(--safe-top);
  background: var(--band); z-index: 35; pointer-events: none;
}

/* --- Message éphémère, états vides, attente ------------------------------ */
.toast {
  position: fixed; left: 50%; top: calc(var(--safe-top) + 12px); z-index: 60;
  translate: -50% -20px; opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px;
  font-weight: 650; font-size: 15px; max-width: calc(100vw - 32px); width: max-content;
  transition: opacity .2s, translate .2s;
}
.toast.show { opacity: 1; translate: -50% 0; box-shadow: var(--shadow); }
.toast.error { background: var(--bad); color: #fff; border-radius: 14px; }
.toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 14px; padding-right: 8px; }
.toast button { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 750; text-decoration: underline; padding: 4px 8px; cursor: pointer; }
.empty { text-align: center; padding: 26px 12px; }
.empty-icon svg { width: 44px; height: 44px; stroke: var(--faint); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; margin: 0 auto 8px; }
.empty p { color: var(--muted); margin: 6px auto 18px; max-width: 32ch; }
.empty .btn { width: auto; padding: 0 24px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 14px; }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite, appear .2s .35s both; margin: 40px auto;
}
@keyframes spin { to { rotate: 360deg; } }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

/* --- Mises à jour (voir js/updater.js) ----------------------------------- */
.update-banner {
  position: fixed; left: 50%; translate: -50% 0; top: calc(var(--safe-top) + 10px); z-index: 55;
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100vw - 32px);
  padding: 10px 16px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--ink); color: var(--bg); font: inherit; font-size: 15px; box-shadow: var(--shadow);
}
.update-banner b { text-decoration: underline; text-underline-offset: 3px; }
.ptr {
  position: fixed; left: 50%; top: calc(var(--safe-top) - 34px); z-index: 34;
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel); color: var(--muted); box-shadow: var(--shadow);
  transform: translate(-50%, 0); opacity: 0; transition: opacity .15s, color .15s; pointer-events: none;
}
.ptr.show { opacity: 1; }
.ptr.ready, .ptr.loading { color: var(--accent-ink); }
.ptr svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ptr.loading svg { display: none; }
.ptr.loading::after { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }

/* --- Grands écrans : disposition du Sheet -------------------------------- */
@media (min-width: 700px) {
  .view { padding-top: calc(var(--safe-top) + 28px); }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .mlayout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mlayout .a-kpis, .mlayout .a-line, .mlayout .a-grid { grid-column: 1 / -1; }
  .ylayout .a-kpis, .ylayout .a-bars, .ylayout .a-recap { grid-column: 1 / -1; }
}
@media (min-width: 1100px) {
  /* Comme l'onglet du Sheet : en haut courbe + donut, au milieu la vue
     hebdomadaire + le top 5, en bas la grille + le bilan */
  .mlayout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 340px;
    grid-template-areas:
      "kpis kpis kpis"
      "line line donut"
      "weeks weeks top"
      "grid grid bilan";
  }
  .mlayout .a-kpis { grid-area: kpis; }
  .mlayout .a-line { grid-area: line; }
  .mlayout .a-donut { grid-area: donut; }
  .mlayout .a-weeks { grid-area: weeks; }
  .mlayout .a-top { grid-area: top; }
  .mlayout .a-grid { grid-area: grid; }
  .mlayout .a-bilan { grid-area: bilan; }
  .a-donut { display: flex; flex-direction: column; }
  .a-donut .donut-wrap { flex: 1; }
  .wbars { height: 150px; }
  .wlist { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 18px; }
  .wlist .w-top { display: grid; grid-template-columns: 1fr auto; row-gap: 1px; }
  .wlist .wdates { grid-row: 2; grid-column: 1 / -1; }
  .hgrid { width: 100%; }          /* la grille remplit sa carte, comme dans le Sheet */
  .cell { width: 24px; height: 24px; margin: 0 auto; }
  .g-day { width: 26px; }
}
