/* Charte SFS v1.0 : fond noir, accent fuchsia rare (60-30-10), Arial, titres gras.
   Accessibilité : le sens passe par la forme et le texte, jamais par la couleur seule (Cyril est dyschromate). */
:root {
  --bg: #0A0A0A; --card: #1A1A1A; --line: #2C2C2C; --line-strong: #6B6B6B;
  --text: #FFFFFF; --text-2: #B8B8B8; --accent: #E6007E;
  --font: Arial, Helvetica, sans-serif; --mono: "Courier New", Courier, monospace;
  /* échelle d'espacement 4/8 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px; --s8: 32px;
  --radius: 16px; --radius-sm: 12px; --tap: 48px;
  /* 3 graisses : 400 / 600 / 700 (charte) ; tailles : 12 meta, 14 secondaire, 16 corps */
  --fs-meta: .75rem; --fs-sec: .875rem; --fs-body: 1rem; --fs-h2: 1.25rem; --fs-h1: 1.75rem;
  /* mouvement */
  --m-100: 100ms; --m-150: 150ms; --m-200: 200ms; --m-300: 300ms;
  --ease-out: cubic-bezier(.16, 1, .3, 1); --ease-in: cubic-bezier(.7, 0, .84, 0);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 400 var(--fs-body)/1.55 var(--font);
  display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
/* Seul le contenu défile ; le bandeau d'onglets a sa propre place (jamais superposé). */
main {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: calc(var(--s4) + env(safe-area-inset-top)) var(--s4) var(--s8);
}
/* Entrée en cascade : chaque bloc arrive de 8 px plus bas en fondu, décalé de 40 ms (6 blocs max). */
main.enter > * { animation: enter var(--m-200) var(--ease-out) both; }
main.enter > :nth-child(2) { animation-delay: 40ms; }
main.enter > :nth-child(3) { animation-delay: 80ms; }
main.enter > :nth-child(4) { animation-delay: 120ms; }
main.enter > :nth-child(5) { animation-delay: 160ms; }
main.enter > :nth-child(n+6) { animation-delay: 200ms; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1 { font-size: 1.5rem; line-height: 1.2; letter-spacing: -.01em; margin: 0; font-weight: 700; }
h2 { font-size: var(--fs-h2); line-height: 1.2; margin: var(--s8) 0 var(--s2); font-weight: 700; color: var(--accent); }
h3 { font-size: var(--fs-body); margin: var(--s4) 0 var(--s1); font-weight: 600; }
p { margin: 0 0 var(--s2); }
.muted { color: var(--text-2); font-size: var(--fs-sec); }
.label { color: var(--text-2); font-size: var(--fs-meta); letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }
.mono { font-family: var(--mono); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* En-tête du jour */
.head { margin-bottom: var(--s2); }
.link { display: block; margin: var(--s1) auto 0; min-height: 44px; padding: 0 var(--s2); background: none; border: 0; color: var(--text-2); font: 600 var(--fs-sec) var(--font); cursor: pointer; border-radius: 8px; }
.link:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.head .date::first-letter { text-transform: uppercase; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.chip { display: inline-flex; align-items: center; gap: var(--s2); min-height: 32px; padding: 0 var(--s3); border: 1px solid var(--line); border-radius: 999px; font-size: var(--fs-sec); color: var(--text-2); }
.chip b { color: var(--text); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); margin: var(--s3) 0; }

/* Trois cercles côte à côte : série en cours, total, meilleure série (chacun vers son prochain jalon) */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); margin: var(--s6) 0 var(--s2); }
.stat { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s1); min-width: 0; }
.ring { position: relative; width: 100%; max-width: 104px; aspect-ratio: 1; }
.ring svg { width: 100%; height: 100%; display: block; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 8; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; }
.stat[data-stat="total"] .ring-fg { stroke: var(--text); }
.stat[data-stat="best"] .ring-fg { stroke: var(--text-2); }
.ring-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.stat .big { font: 700 1.75rem/1 var(--mono); }
.stat-label { margin-top: var(--s2); font-size: var(--fs-sec); line-height: 1.25; font-weight: 600; }
.stat-sub { font-size: var(--fs-meta); line-height: 1.3; color: var(--text-2); }
.stat.hard .ring-bg { stroke: var(--line-strong); }
.note { text-align: center; font-size: var(--fs-sec); color: var(--text-2); margin: var(--s3) 0 0; }

.phrase { margin: var(--s3) 0; padding-left: var(--s3); border-left: 3px solid var(--accent); font-size: var(--fs-body); }
.banner { background: var(--card); border: 1px solid var(--text); border-radius: var(--radius-sm); padding: var(--s3) var(--s4); margin: var(--s3) 0; }
.banner p:last-child { margin-bottom: 0; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: var(--s4) 0 var(--s2); }
.section-head h2 { margin: 0; }
.section-head .count { font: 700 var(--fs-sec)/1 var(--mono); color: var(--text-2); }
.section-head .count.ok { color: var(--text); }

/* Habitudes */
.habit {
  display: flex; align-items: center; gap: var(--s4); width: 100%; min-height: 72px; text-align: left;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--s3) var(--s4); margin: var(--s2) 0; font: inherit; cursor: pointer;
  transition: transform var(--m-100) var(--ease-out), opacity var(--m-150) var(--ease-out);
}
.habit:active { transform: scale(.98); }
.habit .body { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 2px; }
.habit .top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.habit .meta.time { font-size: var(--fs-meta); }
.habit .name { font-weight: 700; }
.habit .meta { font-size: var(--fs-sec); line-height: 1.4; color: var(--text-2); }
.habit .state { flex: none; font-size: var(--fs-meta); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.habit .shape { width: 40px; height: 40px; }
.habit[data-level="full"] { border-color: var(--accent); }
.habit[data-level="min"] { border-color: var(--text); border-style: dashed; }
.habit.na { min-height: 56px; opacity: .75; cursor: default; }
.habit.na .shape { width: 28px; height: 28px; margin: 0 6px; }
.habit.pop .shape { animation: pop var(--m-200) var(--ease-out); }
@keyframes pop { from { transform: scale(.8); opacity: .4; } to { transform: scale(1); opacity: 1; } }
/* La coche se dessine (200 ms) après l'apparition du rond. */
.habit.pop .s-mark-on-fill { stroke-dasharray: 20; stroke-dashoffset: 20; animation: draw var(--m-200) var(--ease-out) 60ms forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Boutons et segments */
.btn {
  min-height: var(--tap); padding: 0 var(--s4); border-radius: var(--radius-sm); font: 600 var(--fs-body) var(--font); cursor: pointer;
  background: transparent; color: var(--text); border: 1px solid var(--line-strong);
  transition: transform var(--m-100) var(--ease-out), opacity var(--m-150) var(--ease-out);
}
.btn:active { transform: scale(.98); }
.btn.sm { min-height: 44px; font-size: var(--fs-sec); }
.row.small { margin-top: var(--s4); }
.btn.primary { background: var(--accent); border-color: var(--accent); font-weight: 700; }
.btn[aria-pressed="true"] { border-color: var(--text); background: var(--line); }
.row { display: flex; gap: var(--s2); flex-wrap: wrap; margin: var(--s3) 0; }
.row .btn { flex: 1 1 auto; }

.seg { display: flex; gap: 0; margin: var(--s2) 0; padding: var(--s1); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); }
.seg button { flex: 1; min-height: 40px; font: 600 var(--fs-sec) var(--font); color: var(--text-2); background: transparent; border: 1px solid transparent; border-radius: 8px; cursor: pointer; transition: opacity var(--m-150) var(--ease-out); }
.seg button[aria-pressed="true"] { color: var(--text); background: var(--line); border-color: var(--line-strong); }

.habit:focus-visible, .btn:focus-visible, .tab:focus-visible, .seg button:focus-visible, input:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }

/* Bandeau d'onglets (hors flux de défilement) */
#tabs { flex: none; display: flex; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tab {
  flex: 1; min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s1);
  background: none; border: 0; border-top: 2px solid transparent; color: var(--text-2); font: 600 var(--fs-meta)/1.2 var(--font); cursor: pointer; padding: var(--s1) 2px 0;
  transition: opacity var(--m-150) var(--ease-out);
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--text); border-top-color: var(--accent); }
.tab[aria-current="page"] svg { stroke: var(--accent); }
.tab[data-pop] svg { animation: pop var(--m-200) var(--ease-out); }

/* Plan */
.timeline { list-style: none; margin: var(--s2) 0; padding: 0; }
.timeline li { display: flex; gap: var(--s4); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.timeline time { font-family: var(--mono); min-width: 104px; color: var(--text-2); font-size: var(--fs-sec); }
.timeline .tag { font-size: var(--fs-sec); color: var(--text-2); display: block; }
table.cycle { width: 100%; border-collapse: collapse; font-size: var(--fs-sec); }
table.cycle th, table.cycle td { text-align: left; padding: var(--s2) var(--s1); border-bottom: 1px solid var(--line); vertical-align: top; }
table.cycle th { color: var(--text-2); font-weight: 600; }
table.cycle tr.today { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Progrès */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s1); }
.cal .dow { text-align: center; font-size: var(--fs-meta); color: var(--text-2); }
.cal .cell { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--s1) 0; font-size: var(--fs-meta); border-radius: 8px; }
.cal .cell.today { outline: 2px solid var(--accent); }
.cal .cell svg { width: 24px; height: 24px; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: var(--fs-sec); margin: var(--s2) 0 var(--s4); }
.legend span { display: inline-flex; align-items: center; gap: var(--s2); }
.legend svg { width: 20px; height: 20px; }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: var(--s2) 0; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.quote { font-size: var(--fs-h2); line-height: 1.3; font-weight: 700; margin: var(--s6) 0; }
ul.plain { padding-left: var(--s6); margin: var(--s1) 0 var(--s2); }
ul.plain li { margin-bottom: var(--s2); }
input[type="date"], input[type="file"] { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); min-height: var(--tap); padding: 0 var(--s3); width: 100%; }
label { display: block; font-size: var(--fs-sec); color: var(--text-2); margin: var(--s3) 0 var(--s1); }
.err { background: var(--card); border: 1px solid var(--text); border-left: 6px solid var(--accent); border-radius: 8px; padding: var(--s2) var(--s3); margin: var(--s2) 0; }

/* formes (jamais la couleur seule) */
.shape { flex: none; }
.s-fill { fill: var(--accent); }
.s-mark-on-fill { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.s-ring { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.s-mark { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; }
.s-grey { fill: #3A3A3A; stroke: var(--text-2); stroke-width: 1.5; }
.s-hatch path { fill: none; stroke: var(--text-2); stroke-width: 1.5; opacity: .6; }
.s-letter { fill: #fff; font: 700 14px var(--font); }
.s-ring-grey { fill: none; stroke: var(--text-2); stroke-width: 2; }
.s-mark-grey { fill: none; stroke: var(--text-2); stroke-width: 2.5; stroke-linecap: round; }
.s-dot { fill: var(--line-strong); }

@media (max-width: 359px) { .stat .big { font-size: 1.5rem; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Page « Aujourd'hui » : tout est centré */
main.center { text-align: center; }
main.center .chips { justify-content: center; }
main.center .phrase { border-left: 0; padding: 0 var(--s2); font-size: 1.125rem; line-height: 1.4; }
main.center .phrase::before { content: ""; display: block; width: 32px; height: 3px; margin: 0 auto var(--s3); background: var(--accent); border-radius: 2px; }
main.center .section-head { flex-direction: column; align-items: center; gap: var(--s1); }
main.center .habit { text-align: center; }
main.center .habit .body { align-items: center; }
main.center .habit .state { margin-top: var(--s1); }
main.center .habit { position: relative; justify-content: center; padding: var(--s3) 64px; }
main.center .habit .shape { position: absolute; left: var(--s4); top: 0; bottom: 0; margin: auto 0; }
main.center .habit.na .shape { left: var(--s4); margin: auto 0; }
main.center .banner { text-align: center; }
main.center .banner .btn { margin-top: var(--s2); }
main.center .err { text-align: left; }

/* Autres écrans : même langage (centré, cartes, cascade) */
main.center h2 { text-align: center; }
main.center .head h1 { text-align: center; }
main.center .head .quote { margin: var(--s4) 0 0; }
main.center .seg { max-width: 420px; margin-left: auto; margin-right: auto; }
main.center .timeline li { flex-direction: column; align-items: center; gap: var(--s1); text-align: center; }
main.center .timeline time { min-width: 0; }
main.center .timeline .what { font-weight: 600; }
main.center .timeline .tag { font-weight: 400; }
.card.day { padding: var(--s3) var(--s4); margin: var(--s2) 0; }
.card.day.today { border-color: var(--accent); }
.day-name { font-weight: 700; margin-bottom: var(--s2); }
.card.block { margin: var(--s3) 0; padding: var(--s6) var(--s4); }
.card.block .label { margin-bottom: var(--s3); }
.line { margin: 0 0 var(--s3); font-size: var(--fs-body); line-height: 1.5; }
.card.block .line:last-child { margin-bottom: 0; }
main.center .legend { justify-content: center; }
main.center .chips .chip svg { width: 16px; height: 16px; }
main.center label { text-align: center; }
main.center input[type="date"] { text-align: center; }
main.center input[type="file"] { text-align: center; }
main.center .row { justify-content: center; }
main.center .cal { text-align: center; }
input[type="file"]::file-selector-button { margin-right: var(--s3); min-height: 36px; padding: 0 var(--s3); border: 1px solid var(--line-strong); border-radius: 8px; background: var(--line); color: var(--text); font: 600 var(--fs-sec) var(--font); cursor: pointer; }
input[type="file"] { color: var(--text-2); font-size: var(--fs-sec); }

/* La devise reste sur une seule ligne : la taille suit la largeur de l'écran. */
.motto { white-space: nowrap; font-size: clamp(.75rem, 4.1vw, 1.25rem) !important; letter-spacing: -.005em; }
