:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #16191d;
  --muted: #6b7280;
  --line: #e3e5e9;
  --accent: #e8590c;
  --ok: #2f9e6e;
  --over: #c2255c;
  --part: #b7791f;
  color-scheme: light;
}
/* Sombre : celui du téléphone, sauf si le bouton ☀️/🌙 a forcé un thème (data-theme sur <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1114;
    --card: #191c21;
    --text: #eceef1;
    --muted: #8b929c;
    --line: #2a2f36;
    --ok: #4cc38a;
    --over: #f06595;
    --part: #f0b429;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1114;
  --card: #191c21;
  --text: #eceef1;
  --muted: #8b929c;
  --line: #2a2f36;
  --ok: #4cc38a;
  --over: #f06595;
  --part: #f0b429;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* L'en-tête est fixe : le contenu commence juste sous lui (hauteur mesurée par app.js dans --head-h). */
  padding: var(--head-h, 120px) 0 env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  padding: calc(8px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; justify-content: center; gap: 8px; padding-bottom: 6px; font-size: 14px; }
.brand strong { letter-spacing: .06em; text-transform: uppercase; }
.countdown { color: var(--accent); font-weight: 600; }
.brand { position: relative; }
.theme-btn {
  position: absolute; right: 0; top: -4px; width: 32px; height: 28px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 14px; line-height: 1; padding: 0;
}
.weeknav { display: flex; align-items: center; gap: 8px; }
.nav {
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  font-size: 24px; line-height: 1;
}
.wk {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  background: none; border: 0; padding: 2px;
}
#wkTitle { font-weight: 700; font-size: 17px; }
#wkRange { font-size: 13px; }

.goals {
  margin: 12px 16px; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
}
.goal {
  display: grid; grid-template-columns: 1fr 56px 64px; align-items: center; gap: 4px;
}
.goals-head { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding-bottom: 4px; }
.goal { padding: 5px 0; border-top: 1px solid var(--line); }
.glabel { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.glabel i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.count {
  text-align: center; font-variant-numeric: tabular-nums; font-weight: 600;
  color: var(--muted); border-radius: 8px; padding: 2px 0;
}
.count.part { color: var(--part); }
.count.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.count.over { color: var(--over); background: color-mix(in srgb, var(--over) 14%, transparent); }
.left { text-align: right; font-size: 13px; color: var(--muted); }
.left.ok { color: var(--ok); font-weight: 600; }
.left.part { color: var(--part); }
.left.over { color: var(--over); }

.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 16px 0; }
.tools .ghost { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 9px 6px; }
@media (max-width: 480px) { .tools { grid-template-columns: repeat(2, 1fr); } }
.copy {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 0 16px 12px; color: var(--muted);
}
.copy span { flex-basis: 100%; }
.ghost {
  border: 1px solid var(--line); background: var(--card);
  border-radius: 10px; padding: 8px 12px;
}
.ghost:disabled, .primary:disabled { opacity: .45; }

main { display: grid; gap: 10px; padding: 0 16px; }
@media (min-width: 820px) {
  main { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
  .goals { max-width: 520px; }
}
.day {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; scroll-margin-top: calc(var(--head-h, 120px) + 8px);
}
/* Séance (ou jour) que Claude vient de modifier : elle clignote plusieurs fois. */
.day.flash { animation: flash .8s ease-in-out 4; }
.chip.flash { animation: flash-chip .8s ease-in-out 5; }
@keyframes flash { 50% { box-shadow: 0 0 0 3px var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); } }
@keyframes flash-chip { 50% { box-shadow: 0 0 0 3px var(--accent); transform: scale(1.06); } }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day h3 { margin: 0 0 6px; font-size: 15px; }
.day.today h3::after { content: "hoy"; margin-left: 8px; font-size: 11px; font-weight: 600; color: var(--accent); text-transform: uppercase; }
.slot { display: grid; grid-template-columns: 48px 1fr; gap: 8px; align-items: start; padding: 4px 0; }
.slot + .slot { border-top: 1px dashed var(--line); }
.slot-label { font-size: 12px; color: var(--muted); padding-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: flex; flex-direction: column; align-items: flex-start; text-align: left;
  border: 0; border-left: 4px solid var(--c); border-radius: 8px;
  background: color-mix(in srgb, var(--c) 14%, var(--card));
  padding: 6px 10px; max-width: 100%;
}
.chip-main { font-weight: 600; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.has-details { color: var(--muted); font-weight: 700; }
.tick-badge {
  font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px;
  background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok);
}
.chip-note { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.add {
  min-width: 36px; height: 34px; border-radius: 8px;
  border: 1px dashed var(--line); background: none; color: var(--muted); font-size: 20px; line-height: 1;
}

.foot { display: flex; justify-content: space-between; padding: 16px; font-size: 12px; }

/* Fenêtres : hauteur calée sur la partie visible de l'écran (dvh : sans les barres de Safari),
   en-tête fixe avec le bouton ✕, contenu qui défile dessous. */
dialog {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 520px;
  background: var(--card); color: var(--text);
  border-radius: 18px 18px 0 0;
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 16px - env(safe-area-inset-top));
  overflow: hidden;
}
dialog[open] { display: flex; flex-direction: column; }
dialog.tall { height: calc(100vh - 80px); height: calc(100dvh - 16px - env(safe-area-inset-top)); }
@media (min-width: 600px) { dialog { margin: auto; border-radius: 18px; } }
dialog::backdrop { background: rgb(0 0 0 / .55); }
body:has(dialog[open]) { overflow: hidden; }
.dlg-head {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--line);
}
.dlg-head h2 { flex: 1; margin: 0; font-size: 17px; outline: none; }
.close {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font-size: 18px; font-weight: 700; line-height: 1;
}
.dlg-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: grid; gap: 12px; align-content: start;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
}
.dlg-body p { margin: 0; }
.actions.wrap { flex-wrap: wrap; }
#sheet.adding .edit-only { display: none; }
.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.type {
  text-align: center; padding: 12px 4px; border-radius: 10px;
  border: 1px solid var(--line); border-left: 4px solid var(--c);
  background: var(--card); font-weight: 600; font-size: 14px;
}
.type.selected { background: color-mix(in srgb, var(--c) 22%, var(--card)); border-color: var(--c); }
.type.add-type { border-style: dashed; border-left: 1px dashed var(--line); color: var(--muted); font-weight: 500; }
.new-type-box { display: grid; gap: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: 12px; }
.new-type-box[hidden] { display: none; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--card); background: var(--c); box-shadow: 0 0 0 1px var(--line); padding: 0; }
.swatch.selected { box-shadow: 0 0 0 3px var(--c); }
.swatches input[type=color] { width: 40px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; }
.custom-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.custom-list:empty { display: none; }
.custom-tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 8px; border-radius: 8px; border: 1px solid var(--line); border-left: 4px solid var(--c); }
.custom-tag button { border: 0; background: none; color: var(--muted); padding: 2px 6px; font-size: 13px; }
.note {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
}
textarea.note { resize: vertical; min-height: 90px; }
.row { display: flex; align-items: center; gap: 8px; }
.row > .muted { min-width: 64px; font-size: 14px; }
.row select.note { flex: 1; padding: 9px 10px; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span {
  display: block; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); font-weight: 600;
}
.pill input:checked + span { background: color-mix(in srgb, var(--ok) 20%, var(--card)); border-color: var(--ok); color: var(--ok); }
.pill input:focus-visible + span { outline: 2px solid var(--accent); }
.actions { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.primary { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.danger { background: none; border: 0; color: var(--over); padding: 10px 4px; }
.danger-btn { background: var(--over); color: #fff; border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.block { display: block; width: 100%; text-align: center; text-decoration: none; padding: 12px 14px; }
.small { font-size: 13px; margin: 0; }

/* Fenêtres secondaires : semaine type, confirmation, historique, agenda */
.hist-types { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.hist-types .type { flex: none; padding: 8px 12px; }
.hist-list { display: grid; gap: 8px; align-content: start; }
.hist {
  display: grid; gap: 4px; text-align: left; width: 100%;
  background: color-mix(in srgb, var(--c) 10%, var(--card)); border: 0; border-left: 4px solid var(--c);
  border-radius: 10px; padding: 10px 12px;
}
.hist-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hist-details { white-space: pre-wrap; font-size: 13px; color: var(--muted); }

/* Recommandations de Claude */
.insights { margin: -4px 16px 12px; }
.tips {
  display: flex; gap: 0; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
}
.tips::-webkit-scrollbar { display: none; }
/* Chaque conseil a la couleur de son type (--k) */
.tip {
  flex: 0 0 100%; scroll-snap-align: start; box-sizing: border-box;
  padding: 8px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--k) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--k) 35%, var(--line)); border-left: 4px solid var(--k);
}
.tip-tag {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .02em;
  color: var(--k); text-transform: uppercase; margin-bottom: 2px;
}
.tip-text {
  margin: 0; font-size: 14px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dots { display: flex; justify-content: center; gap: 5px; padding-top: 5px; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: color-mix(in srgb, var(--text) 25%, transparent); }
.dot.on { background: var(--accent); }

/* Messages pour Claude */
.fab {
  position: fixed; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 15;
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--accent); font-size: 24px; box-shadow: 0 6px 20px rgb(0 0 0 / .3);
}
.fab-badge {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; border-radius: 10px;
  background: var(--text); color: var(--card); font-size: 12px; font-weight: 700; line-height: 20px; padding: 0 5px;
}
.foot { padding-bottom: 90px; }
.msg-form { display: grid; gap: 10px; }
.attach { cursor: pointer; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 64px; height: 64px; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb span { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: rgb(0 0 0 / .6); color: #fff; font-size: 13px; line-height: 18px; }
.msg { display: grid; gap: 6px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.msg-text { margin: 0; white-space: pre-wrap; }
.reply { padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.reply p { margin: 2px 0 0; white-space: pre-wrap; font-size: 14px; }
.status { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 6px; background: color-mix(in srgb, var(--part) 18%, transparent); color: var(--part); }
.status.error { background: color-mix(in srgb, var(--over) 18%, transparent); color: var(--over); }

/* Séances Garmin */
.act-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding-top: 6px; margin-top: 4px; border-top: 1px dashed var(--line); font-size: 12px; }
.act-tag { color: #11a9ed; font-weight: 700; }
.act-item { color: var(--muted); }
.act-people { display: grid; gap: 10px; }
.act-person { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }

/* Bandeau « Deshacer » */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  background: var(--text); color: var(--card); border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 6px 24px rgb(0 0 0 / .25);
}
.toast span { flex: 1; font-size: 14px; }
.toast button { background: none; border: 0; color: var(--accent); font-weight: 700; padding: 4px; }

/* Page de connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form {
  width: 100%; max-width: 340px; display: grid; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px;
}
.login h1 { margin: 0; font-size: 20px; }
.login .err { display: none; color: var(--over); margin: 0; font-size: 14px; }
.login .err:target { display: block; }

/* Mejoras (🛠️) : bouton au-dessus de 💬, conversation avec Claude */
.fab-dev { bottom: calc(86px + env(safe-area-inset-bottom)); width: 46px; height: 46px; right: 21px; font-size: 20px; background: var(--card); border: 1px solid var(--line); }
body.preview .fab-dev { display: none; }
.preview-banner { margin: -4px -16px 6px; padding: 3px 8px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; text-align: center; }
.dev-chat { display: grid; gap: 8px; }
.dev-chat:empty { display: none; }
.bubble { display: grid; gap: 4px; padding: 8px 10px; border-radius: 12px; max-width: 92%; }
.bubble p { margin: 0; white-space: pre-wrap; font-size: 14px; overflow-wrap: anywhere; }
.bubble strong { font-size: 12px; }
.bubble.me { justify-self: end; background: color-mix(in srgb, var(--accent) 14%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); }
.bubble.claude { justify-self: start; background: var(--card); border: 1px solid var(--line); }
.dev-progress { font-size: 12px; color: var(--muted); padding: 0 4px; }
.dev-progress.typing span { animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.dev-system { font-size: 13px; text-align: center; color: var(--muted); padding: 2px 8px; overflow-wrap: anywhere; }
.dev-system a { color: var(--accent); font-weight: 600; }
#devOpen { text-decoration: none; color: var(--text); }
.status.published { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.status.discarded, .status.reverted { background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); }
/* Clin d'œil en haut de la fenêtre des mejoras */
.god {
  display: grid; gap: 2px; text-align: center; padding: 12px 8px; border-radius: 12px;
  background: linear-gradient(135deg, #1a0b2e, #2b0d0d); border: 1px solid #ff4d00; box-shadow: 0 0 18px rgb(255 77 0 / .35) inset;
}
.god-title {
  font-weight: 900; font-size: 22px; letter-spacing: .12em;
  background: linear-gradient(90deg, #ffd43b, #ff6b00, #ff2d55, #ffd43b); background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: god-shine 4s linear infinite, god-glitch 3.5s steps(1) infinite;
}
.god-sub { font-size: 12px; font-weight: 700; color: #ffb38a; text-transform: uppercase; letter-spacing: .06em; }
@keyframes god-shine { to { background-position: 300% 0; } }
@keyframes god-glitch { 0%, 92%, 100% { transform: none; } 94% { transform: translate(-2px, 1px) skewX(-8deg); } 96% { transform: translate(2px, -1px) skewX(6deg); } }
@media (prefers-reduced-motion: reduce) { .god-title { animation: none; } }
.god-quote { margin: 4px 0 0; text-align: center; font-size: 12px; font-style: italic; color: var(--muted); }
/* Mejoras : cartes des conversations (2 par ligne) */
.dev-view { display: grid; gap: 10px; }
.dev-view[hidden] { display: none; }
.dev-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.dev-cards:empty { display: none; }
.dev-card {
  display: grid; align-content: start; gap: 4px; min-height: 118px; padding: 10px; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
}
.dev-card.current { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
.dev-card .status { justify-self: start; font-size: 11px; }
.dev-card strong { font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dev-card-desc { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dev-card-meta { font-size: 11px; color: var(--muted); margin-top: auto; }
.status.chat, .status.preview { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.status.busy { animation: blink 1.6s ease-in-out infinite; }
.back { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); font-size: 22px; line-height: 1; padding: 0 0 2px; flex: none; }
#devTitle { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#devUndo { justify-self: start; }
/* Carte « versión de prueba lista » */
.dev-ready {
  display: grid; gap: 10px; padding: 14px; border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--ok) 45%, var(--line));
  background: color-mix(in srgb, var(--ok) 10%, var(--card));
}
.dev-ready-head { display: flex; gap: 10px; align-items: flex-start; }
.dev-ready-icon { font-size: 26px; line-height: 1; }
.dev-ready-head div { display: grid; gap: 2px; }
.dev-ready-head span { font-size: 13px; color: var(--muted); }
.dev-open {
  display: block; text-align: center; padding: 11px 14px; border-radius: 10px; font-weight: 600; text-decoration: none;
  color: var(--text); background: var(--card); border: 1px solid var(--line);
}
.dev-publish { width: 100%; padding: 12px 14px; font-size: 16px; background: #2f9e6e; }
.dev-discard { justify-self: center; background: none; border: 0; color: var(--muted); font-size: 13px; text-decoration: underline; padding: 4px; }
