/* Veille : mode sombre neutre (gris, sans teinte), sections en cartes, chiffres clés en tuiles.
   Le jaune est réservé aux coups de barre ; les quatre couleurs de phases au sommeil. */

:root {
  color-scheme: dark;
  --bg: #0f0f11;
  --card: #18181b;
  --card-2: #212125;
  --border: #2a2a2f;
  --text: #f4f4f5;
  --text-2: #a1a1aa;
  --muted: #8b8b94;
  --grid: #26262b;
  --axis: #3a3a40;
  --data: #d4d4d8;
  --heart: #f87171;
  --hi: #facc15;
  --hi-ink: #18181b;
  --deep: #3987e5;
  --light: #199e70;
  --rem: #9085e9;
  --awake: #d95926;
  --danger: #f87171;
  --radius: 16px;
  --gutter: 16px;
  --tabs-h: 64px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 84px);
}
h1, h2, h3, p, dl, dd, ul, ol, figure, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: var(--gutter); top: 8px; z-index: 50; background: var(--card); padding: 8px 12px; }

/* ---------- En-tête et navigation ---------- */

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px var(--gutter);
  /* Pas de backdrop-filter ici : il piégerait la barre d'onglets fixe du téléphone. */
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.wordmark { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 18px; text-decoration: none; margin-right: auto; }
.logo { width: 22px; height: 22px; border-radius: 7px; background: var(--hi); box-shadow: inset -7px -5px 0 -2px var(--card); }
.status { font-size: 14px; color: var(--text-2); text-decoration: none; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); }
.status:hover, .status[aria-current='page'] { color: var(--text); background: var(--card-2); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding: 6px 4px env(safe-area-inset-bottom);
  background: rgb(24 24 27 / 0.95); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11.5px; font-weight: 500; text-decoration: none; color: var(--muted); border-radius: 12px;
}
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current='page'] { color: var(--text); }
.tabs a[aria-current='page'] svg { stroke-width: 2.2; }

@media (min-width: 860px) {
  body { padding-bottom: 96px; }
  .top { padding: 12px max(var(--gutter), calc((100vw - 1100px) / 2)); }
  .wordmark { margin-right: 12px; }
  .tabs { position: static; height: auto; padding: 0; border: 0; background: none; backdrop-filter: none; gap: 2px; margin-right: auto; justify-content: flex-start; }
  .tabs a { flex: none; flex-direction: row; gap: 7px; padding: 8px 14px; font-size: 14px; }
  .tabs svg { width: 18px; height: 18px; }
  .tabs a:hover { color: var(--text); }
  .tabs a[aria-current='page'] { background: var(--card-2); }
}

main { max-width: 1100px; margin: 0 auto; padding: 18px var(--gutter) 0; outline: none; }
main:focus, main:focus-visible { outline: none; }
main.is-loading { opacity: 0.55; transition: opacity 150ms; }

/* ---------- Texte ---------- */

.title { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.hero { font-size: 32px; font-weight: 700; }
.lede { margin-top: 12px; max-width: 68ch; color: var(--text-2); font-size: 15px; }
.lede strong { color: var(--text); font-weight: 600; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
h3.sub { margin: 20px 0 8px; }
.note { color: var(--muted); font-size: 13.5px; max-width: 72ch; margin-top: 10px; }
.error { color: var(--danger); }
.period { color: var(--text-2); font-size: 14px; }
.empty { margin-top: 16px; padding: 28px 20px; text-align: center; color: var(--text-2); background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- Cartes ---------- */

main section {
  margin-top: 16px; padding: 18px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
}
main section > h2 + * { margin-top: 12px; }
main section section { padding: 0; border: 0; background: none; }
.cols { display: grid; gap: 0 16px; }
@media (min-width: 860px) { .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.banner { background: var(--card-2); border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px; font-size: 14px; color: var(--text-2); margin-bottom: 14px; }
.banner a { color: var(--text); font-weight: 600; }

/* ---------- Tuiles de chiffres clés ---------- */

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
@media (min-width: 1040px) { .stats { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-auto-flow: column; } }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; display: flex; flex-direction: column; }
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.stat-label { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); }
.stat-value { margin-top: 6px; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value small { font-size: 14px; font-weight: 500; color: var(--text-2); letter-spacing: 0; }
.stat-sub { margin-top: 4px; font-size: 13px; color: var(--muted); }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--heart); flex: none; }
.live.stale .live-dot { background: var(--axis); }
.refresh { border: 0; background: var(--card-2); color: var(--text-2); width: 28px; height: 28px; border-radius: 50%; font-size: 15px; line-height: 1; }
.refresh:hover { color: var(--text); }
.refresh:disabled { opacity: 0.4; }
.live-spark { margin-top: 8px; height: 28px; }
.live-spark svg { display: block; width: 100%; height: 28px; }
.live-spark:empty { display: none; }
.live .spark { fill: none; stroke: var(--heart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.live-hint { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.live-hint:empty { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .live:not(.stale) .live-dot { animation: beat 1.6s ease-in-out infinite; }
  @keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.5); } 30% { transform: scale(1); } }
}

/* ---------- Navigation entre jours, période ---------- */

.daynav { display: flex; align-items: center; gap: 6px; }
.daynav .date { margin-right: auto; font-size: 20px; font-weight: 700; }
.daynav .date::first-letter { text-transform: uppercase; }
.daynav a, .daynav span.off {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border); text-decoration: none; font-size: 20px; line-height: 1;
}
.daynav a:hover { background: var(--card-2); }
.daynav span.off { color: var(--axis); }
.daynav a.today { width: auto; padding: 0 14px; border-radius: 999px; font-size: 13px; }

.filters { display: inline-flex; padding: 3px; gap: 2px; background: var(--card); border: 1px solid var(--border); border-radius: 999px; }
.filters button { border: 0; background: none; border-radius: 999px; padding: 6px 13px; font-size: 13px; color: var(--text-2); }
.filters button[aria-pressed='true'] { background: var(--card-2); color: var(--text); font-weight: 600; }

/* ---------- Graphiques ---------- */

.chart { position: relative; margin-top: 12px; }
.chart svg { display: block; width: 100%; overflow: visible; touch-action: pan-y; }
.chart svg:focus-visible { outline-offset: 6px; }
.chart text { font: 500 11.5px var(--font); fill: var(--muted); }
.chart .lane-label { fill: var(--text-2); }
.chart .end-label { fill: var(--text); font-weight: 600; font-size: 12.5px; }
.chart .flag { fill: var(--hi-ink); font-weight: 700; font-size: 11.5px; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .grid.strong { stroke: var(--axis); }
.chart .line { fill: none; stroke: var(--data); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .band { fill: var(--data); opacity: 0.08; }
.chart .mark { fill: var(--data); }
.chart .dot { fill: var(--data); stroke: var(--card); stroke-width: 2; }
.chart .cross { stroke: var(--text); stroke-width: 1; opacity: 0.4; }
.chart .target { stroke: var(--text-2); stroke-width: 1; }
.chart .hi { fill: var(--hi); }
.chart .now { stroke: var(--text); stroke-width: 1; opacity: 0.6; }
.chart .hit { fill: transparent; }
.chart .cls { fill: var(--axis); }
.chart .col.lift { fill: var(--text); }
.chart .rowbg { fill: transparent; }
.chart .row:hover .rowbg, .chart .row.sel .rowbg { fill: var(--card-2); }
.chart .flagdot { fill: var(--hi); stroke: var(--card); stroke-width: 2; }
.chart .halo { paint-order: stroke; stroke: var(--card); stroke-width: 4px; stroke-linejoin: round; fill: var(--text-2); }
.chart [role='link'] { cursor: pointer; }
.chart .line.heart { stroke: var(--heart); }
.chart .band.heart { fill: var(--heart); opacity: 0.12; }
.s-DEEP { fill: var(--deep); } .s-LIGHT, .s-ASLEEP { fill: var(--light); } .s-REM { fill: var(--rem); } .s-AWAKE, .s-RESTLESS { fill: var(--awake); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 13px; color: var(--text-2); }
.legend li { display: flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend i.round { border-radius: 50%; }
.k-DEEP { background: var(--deep); } .k-LIGHT { background: var(--light); } .k-REM { background: var(--rem); } .k-AWAKE { background: var(--awake); }
.k-dip { background: var(--hi); }
.k-ink { background: var(--data); }
.k-cls { background: var(--axis); }

.tip {
  position: fixed; z-index: 40; pointer-events: none; max-width: 260px;
  background: var(--card-2); color: var(--text); border: 1px solid var(--axis); border-radius: 10px; padding: 9px 11px;
  font-size: 13px; line-height: 1.4; box-shadow: 0 8px 24px rgb(0 0 0 / 0.45);
}
.tip .t { font-weight: 600; margin-bottom: 3px; }
.tip .r { display: flex; align-items: center; gap: 7px; }
.tip .r b { font-weight: 600; }
.tip .r span { color: var(--text-2); }
.tip .r i { width: 10px; height: 3px; border-radius: 2px; background: var(--data); flex: none; }

details.values { margin-top: 12px; font-size: 13.5px; }
details.values summary { cursor: pointer; color: var(--text-2); width: fit-content; }
details.values summary:hover { color: var(--text); }
.table-wrap { overflow-x: auto; margin-top: 10px; }
table { border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13.5px; }
th, td { text-align: right; padding: 7px 12px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { font-weight: 500; color: var(--text-2); }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
table.compare th, table.compare td { white-space: normal; }
table.compare td { font-weight: 600; font-size: 15px; }

/* ---------- Listes de mesures ---------- */

.facts > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; padding: 11px 0; border-bottom: 1px solid var(--grid); align-items: baseline; }
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--text-2); }
.facts dd.v { font-weight: 600; font-size: 16px; text-align: right; }
.facts dd.d { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }

.meters { display: grid; gap: 14px; }
.meter { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: baseline; }
.meter span { color: var(--text-2); }
.meter b { font-weight: 600; }
.meter b small { font-weight: 400; color: var(--muted); font-size: 13px; }
.meter i { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--card-2); overflow: hidden; }
.meter i::after { content: ''; display: block; height: 100%; width: var(--w); background: var(--c, var(--data)); border-radius: 3px; }

/* ---------- Coups de barre ---------- */

.dip-button {
  position: fixed; right: var(--gutter); z-index: 25;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 14px);
  border: 0; border-radius: 999px; padding: 14px 20px;
  background: var(--hi); color: var(--hi-ink); font-weight: 700; font-size: 15px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.5);
}
.dip-button:active { transform: scale(0.97); }
.dip-button:focus-visible { outline-offset: 4px; }
@media (min-width: 860px) { .dip-button { bottom: 28px; right: max(var(--gutter), calc((100vw - 1100px) / 2)); } }

.dips > li { padding: 13px 0; border-bottom: 1px solid var(--grid); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
.dips > li:last-child { border-bottom: 0; }
.dips .when { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dips .when mark { background: var(--hi); color: var(--hi-ink); border-radius: 6px; padding: 1px 7px; font-weight: 700; }
.dips .day { font-weight: 400; color: var(--text-2); font-size: 14px; }
.dips .ctx { grid-column: 1 / -1; color: var(--text-2); font-size: 14px; max-width: 75ch; }
.dips .ctx q { quotes: '«\00a0' '\00a0»'; font-style: italic; }
.dips button.link { align-self: start; }

/* ---------- Boutons, formulaires, feuille ---------- */

button.primary, a.primary {
  display: inline-block; border: 0; border-radius: 10px; padding: 11px 18px; text-decoration: none;
  background: var(--text); color: var(--bg); font-weight: 600;
}
button.primary:hover, a.primary:hover { background: #ffffff; }
button.quiet, a.quiet {
  display: inline-block; border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px; text-decoration: none;
  background: var(--card-2); font-weight: 500;
}
button.link { border: 0; background: none; padding: 0; color: var(--text-2); font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { color: var(--text); }
button:disabled { opacity: 0.5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13.5px; color: var(--text-2); }
input[type='text'], input[type='password'], textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; background: var(--card-2);
}
input:focus, textarea:focus { outline: none; border-color: var(--text-2); }
input::placeholder, textarea::placeholder { color: var(--muted); }

.sheet {
  border: 1px solid var(--border); padding: 0; width: min(100%, 460px); max-width: 100%;
  margin: auto auto 0; border-radius: 20px 20px 0 0; background: var(--card); color: var(--text);
}
.sheet::backdrop { background: rgb(0 0 0 / 0.6); }
.sheet form { display: grid; gap: 18px; padding: 20px var(--gutter) calc(20px + env(safe-area-inset-bottom)); }
.sheet h2 { font-size: 18px; }
.sheet[open] { animation: rise 180ms ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 600px) { .sheet { margin: auto; border-radius: 20px; } }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices legend { font-size: 13.5px; color: var(--text-2); margin-bottom: 8px; }
.choices label { flex: 1 1 auto; }
.choices input { position: absolute; opacity: 0; pointer-events: none; }
.choices span { display: block; text-align: center; white-space: nowrap; padding: 11px 10px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--border); font-weight: 500; }
.choices input:checked + span { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
.choices input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }
.choices.four { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 480px) { .choices.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 45;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 80px);
  background: var(--card-2); border: 1px solid var(--axis); color: var(--text); border-radius: 12px; padding: 11px 16px;
  font-size: 14px; display: flex; gap: 14px; align-items: center; max-width: calc(100vw - 2 * var(--gutter));
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.45);
}
.toast button { border: 0; background: none; color: var(--hi); font-weight: 600; padding: 0; white-space: nowrap; }

/* ---------- Coach ---------- */

.chat { display: grid; gap: 18px; max-width: 72ch; }
.msg p + p { margin-top: 0.7em; }
.msg.user { justify-self: end; background: var(--card-2); border-radius: 16px 16px 4px 16px; padding: 10px 14px; max-width: 85%; }
.msg .tool { color: var(--muted); font-size: 13px; }
.msg.assistant .tool { margin-bottom: 0.4em; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestions button { border: 1px solid var(--border); background: var(--card-2); border-radius: 999px; padding: 8px 14px; font-size: 14px; text-align: left; }
.suggestions button:hover { border-color: var(--text-2); }
.composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; margin-top: 20px; max-width: 72ch; }
.composer textarea { resize: none; min-height: 46px; max-height: 180px; }
.bilan { max-width: 70ch; color: var(--text); }
.bilan p + p { margin-top: 0.7em; }
.bullets { list-style: disc; padding-left: 1.2em; }
.bullets li + li { margin-top: 0.3em; }

/* ---------- Réglages, connexion ---------- */

.steps { counter-reset: s; display: grid; gap: 10px; max-width: 72ch; }
.steps li { counter-increment: s; padding-left: 32px; position: relative; min-width: 0; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 1px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--card-2);
  display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--text-2);
}
code { font: 500 0.9em ui-monospace, 'Cascadia Mono', Consolas, monospace; background: var(--card-2); border-radius: 5px; padding: 1px 5px; overflow-wrap: anywhere; }
pre { margin: 8px 0 0; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; font-size: 12.5px; line-height: 1.45; }
pre code { background: none; padding: 0; overflow-wrap: normal; }
.login { max-width: 360px; margin: 14vh auto 0; display: grid; gap: 16px; padding: 24px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }

@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: reveal 700ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  @keyframes reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 -20px 0 0); } }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Verdicts et explications ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; vertical-align: middle; }
.badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.badge.good i { background: #22c55e; }
.badge.ok i { background: #a1a1aa; }
.badge.warn i { background: #fab219; }
.badge.bad i { background: #f87171; }
.badge.none i { background: transparent; border: 1px solid var(--muted); }
.stat-badge { margin-top: 10px; }
.facts dd.j { grid-column: 1 / -1; display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; font-size: 13.5px; color: var(--text-2); margin-top: 4px; }
.facts dd.j .badge { margin-top: 1px; }
.facts dd.j span:not(.badge) { flex: 1 1 200px; }
.facts dd.i { grid-column: 1 / -1; }
details.info { margin-top: 6px; font-size: 13.5px; }
details.info summary { cursor: pointer; color: var(--text-2); width: fit-content; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.info summary::-webkit-details-marker { display: none; }
details.info summary::before { content: '?'; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--axis); font-size: 10.5px; font-weight: 700; }
details.info summary:hover { color: var(--text); }
details.info[open] summary { color: var(--text); }
details.info p { margin-top: 8px; padding: 10px 12px; background: var(--card-2); border-radius: 10px; color: var(--text-2); line-height: 1.55; max-width: 72ch; }
main section > h2 + details.info { margin-top: 6px; }
.meter span .badge { margin-left: 6px; }
.meter-info { grid-column: 1 / -1; }
.meter-info details.info { margin-top: 0; }
h3.sub .badge { margin-left: 4px; }

.info-body { margin-top: 8px; padding: 10px 12px; background: var(--card-2); border-radius: 10px; display: grid; gap: 8px; }
details.info .info-body p { margin: 0; padding: 0; background: none; }
.meters + details.info { margin-top: 14px; }

main section { scroll-margin-top: 76px; }

/* ---------- Tuiles colorées avec icône ---------- */
.stat { border-radius: 22px; }
button.stat { font: inherit; color: inherit; text-align: left; cursor: pointer; width: 100%; }
button.stat:hover { filter: brightness(1.12); }
.stat.has-icon { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 10px 14px 10px 10px; align-items: stretch; }
.stat-body { min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 4px 0; }
.stat-icon { display: grid; place-items: center; border-radius: 16px; background: rgb(0 0 0 / 0.28); min-height: 56px; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stat-head { min-height: 0; }
.stat-value { margin-top: 2px; }
.tone-sleep { background: #2d2547; border-color: #3d3361; }
.tone-sleep .stat-icon, .tone-sleep .stat-label { color: #c9bbff; }
.tone-heart { background: #2b2224; border-color: #3e2d31; }
.tone-heart .stat-icon, .tone-heart .stat-label { color: #fca5a5; }
.tone-good { background: #1a3324; border-color: #244832; }
.tone-good .stat-icon, .tone-good .stat-label { color: #86efac; }
.tone-warn { background: #382d12; border-color: #4d3e19; }
.tone-warn .stat-icon, .tone-warn .stat-label { color: #fcd34d; }
.tone-steps { background: #15322f; border-color: #1f4641; }
.tone-steps .stat-icon, .tone-steps .stat-label { color: #5eead4; }
.tone-dip { background: #3a3212; border-color: #4e431a; }
.tone-dip .stat-icon, .tone-dip .stat-label { color: #facc15; }
.tone-plain .stat-icon { color: var(--text-2); background: var(--card-2); }
.tone-sleep .stat-sub, .tone-heart .stat-sub, .tone-good .stat-sub, .tone-warn .stat-sub, .tone-steps .stat-sub, .tone-dip .stat-sub { color: rgb(244 244 245 / 0.7); }
.live .refresh { background: rgb(0 0 0 / 0.25); }
@media (max-width: 480px) {
  .stat.has-icon { grid-template-columns: 1fr; gap: 6px; padding: 12px 14px; }
  .stat-icon { width: 36px; height: 36px; min-height: 0; border-radius: 12px; }
  .stat-icon .ico { width: 19px; height: 19px; }
}

/* ---------- Ta nuit ---------- */
.night-dur { margin-top: 10px; font-size: 40px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; }
.night-dur span { margin-left: 12px; font-size: 17px; font-weight: 600; color: var(--text-2); letter-spacing: 0; white-space: nowrap; }
.night-sum { margin-top: 8px; color: var(--text-2); max-width: 62ch; }
.night .chart { margin-top: 20px; }
.chart .lane-title { fill: var(--text); font-size: 14px; font-weight: 600; }
.chart .lane-val { fill: var(--text-2); font-weight: 500; }
.chart .track { fill: #26262b; }
.chart .conn { stroke: #8b8b94; stroke-width: 1; opacity: 0.45; }
.chart .axis-t { fill: var(--text); font-size: 13px; font-weight: 600; }
.chart .axis-l { fill: var(--text-2); font-size: 12px; font-weight: 600; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.seg button { border: 1px solid var(--axis); background: none; border-radius: 10px; padding: 8px 14px; font-size: 14px; color: var(--text-2); }
.seg button[aria-selected='true'] { background: #e4e4e7; border-color: #e4e4e7; color: #18181b; font-weight: 600; }
.seg button[aria-selected='true']::before { content: '✓'; margin-right: 7px; }
.night details.info { margin-top: 14px; }

.ref { margin-top: 20px; }
.ref-row + .ref-row { margin-top: 20px; }
.ref-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--text-2); }
.ref-head b { color: var(--text); font-weight: 600; }
.ref-bar { position: relative; height: 22px; margin-top: 10px; border-radius: 11px; background: #26262b; }
.ref-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 11px; }
.ref-range { position: absolute; top: -5px; bottom: -5px; border: 1.5px dashed rgb(244 244 245 / 0.55); border-radius: 16px; }
.ref-mark { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--text); box-shadow: 0 0 0 2px var(--card); }
.legend .k-range { width: 18px; height: 10px; border: 1.5px dashed rgb(244 244 245 / 0.55); border-radius: 6px; background: none; }
.legend .k-mark { width: 3px; height: 12px; border-radius: 2px; background: var(--text); }
.ref + .legend, .ref .legend { margin-top: 18px; }

/* Pastilles de verdict teintées */
.badge.good { background: #1a3324; border-color: #244832; color: #bbf7d0; }
.badge.warn { background: #382d12; border-color: #4d3e19; color: #fde68a; }
.badge.bad { background: #3a1d1d; border-color: #552828; color: #fecaca; }
.score-big { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 32px; font-weight: 700; margin-top: 6px; }
.score-big small { font-size: 15px; font-weight: 500; color: var(--text-2); }

/* ---------- Bilan du coach ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.bilan-meta { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13.5px; }
.bilan-meta .ico { width: 18px; height: 18px; color: #a5b4fc; }
.bilan-title { margin: 10px 0 10px; font-size: 24px; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; max-width: 30ch; }
.bilan-card .bilan > p:not(.bilan-meta):not(.bilan-title) { color: var(--text-2); font-size: 16px; }

/* ---------- Barre de navigation : pastille derrière l'icône active ---------- */
.tabs .ic { display: grid; place-items: center; width: 58px; height: 30px; border-radius: 15px; transition: background 150ms; }
.tabs a[aria-current='page'] .ic { background: rgb(255 255 255 / 0.14); }
@media (min-width: 860px) {
  .tabs .ic { width: auto; height: auto; background: none !important; }
}
