/* ───────────── Thèmes ───────────── */
:root,
[data-theme="luxe"] {
  --fond: #f6f0e6;
  --fond-2: #ede2cf;
  --carte: rgba(255, 252, 246, 0.72);
  --carte-forte: #fffcf6;
  --texte: #3f3236;
  --texte-doux: #8c7b72;
  --accent: #b08d57;
  --accent-clair: #e6d5b5;
  --accent-2: #8a5a64;
  --ligne: rgba(176, 141, 87, 0.22);
  --aujourdhui: #b08d57;
  --ombre: 0 18px 50px -24px rgba(90, 64, 40, 0.35);
  --rayon: 14px;
  --police-titre: "Cormorant Garamond", Georgia, serif;
  --police: "Jost", "Segoe UI", sans-serif;
  --titre-poids: 500;
  --titre-espacement: 0.02em;

  --c-rdv: #c9a46a;
  --c-travail: #8f8aa6;
  --c-perso: #b98a95;
  --c-sante: #8fae9e;
  --c-famille: #c99a7d;
  --c-fete: #d2a0a0;
}

[data-theme="zen"] {
  --fond: #f1efe8;
  --fond-2: #e6e8df;
  --carte: rgba(255, 255, 251, 0.62);
  --carte-forte: #fbfbf7;
  --texte: #3d433e;
  --texte-doux: #8a918a;
  --accent: #8aa087;
  --accent-clair: #d6e0d2;
  --accent-2: #b39f84;
  --ligne: rgba(80, 92, 82, 0.12);
  --aujourdhui: #8aa087;
  --ombre: 0 18px 50px -28px rgba(60, 70, 60, 0.3);
  --rayon: 22px;
  --police-titre: "Shippori Mincho", Georgia, serif;
  --police: "Zen Kaku Gothic New", "Segoe UI", sans-serif;
  --titre-poids: 400;
  --titre-espacement: 0.08em;

  --c-rdv: #a9b89a;
  --c-travail: #9aa9b3;
  --c-perso: #c3ad9a;
  --c-sante: #9fbcae;
  --c-famille: #c7b28f;
  --c-fete: #c8a6a0;
}

/* ───────────── Base ───────────── */
* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--police);
  font-weight: 400;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100dvh;
  transition: background 0.8s ease, color 0.8s ease;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.fond {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

[data-theme="luxe"] .fond {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(214, 186, 132, 0.35), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(178, 120, 132, 0.16), transparent 60%),
    linear-gradient(180deg, var(--fond), var(--fond-2));
}
[data-theme="luxe"] .fond::after {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid var(--ligne);
  border-radius: 6px;
}

[data-theme="zen"] .fond {
  background:
    radial-gradient(800px 500px at 100% 0%, rgba(170, 190, 165, 0.28), transparent 65%),
    linear-gradient(180deg, var(--fond), var(--fond-2));
}
/* un ensō discret */
[data-theme="zen"] .fond::after {
  content: "";
  position: absolute;
  width: 62vmin;
  height: 62vmin;
  right: -14vmin;
  bottom: -16vmin;
  border-radius: 50%;
  border: 14px solid rgba(110, 125, 108, 0.06);
  border-right-color: transparent;
  transform: rotate(-30deg);
}

/* ───────────── En-tête ───────────── */
.entete {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: max(40px, env(safe-area-inset-top)) clamp(16px, 5vw, 64px) 18px;
}

.surtitre {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

h1 {
  margin: 0;
  font-family: var(--police-titre);
  font-weight: var(--titre-poids);
  letter-spacing: var(--titre-espacement);
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1;
  text-transform: capitalize;
}

.nav { display: flex; gap: 8px; align-items: center; }

.icone,
.bouton-vue {
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--ligne);
  background: var(--carte);
  backdrop-filter: blur(8px);
  transition: transform 0.2s ease, border-color 0.3s ease, background 0.3s ease;
}
.icone { width: 42px; font-size: 1.4rem; line-height: 1; display: grid; place-items: center; }
.icone:hover, .bouton-vue:hover { transform: translateY(-1px); border-color: var(--accent); }

.bouton-vue {
  padding: 0 18px;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-left: 6px;
}
body[data-vue="annee"] .bouton-vue { background: var(--accent); color: #fff; border-color: var(--accent); }

.theme .pastille {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9a46a 50%, #8aa087 50%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.alarme-suivante {
  font-size: 0.8rem;
  color: var(--texte-doux);
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-clair) 45%, transparent);
  margin-right: 6px;
  white-space: nowrap;
}

/* ───────────── Contenu ───────────── */
.contenu {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(260px, 1fr);
  gap: clamp(16px, 2.5vw, 32px);
  padding: 0 clamp(16px, 5vw, 64px);
  align-items: start;
}

.calendrier,
.carte {
  background: var(--carte);
  border: 1px solid var(--ligne);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  backdrop-filter: blur(14px);
}

.calendrier { padding: 18px; }

body[data-vue="annee"] .vue-mois,
body[data-vue="mois"] .vue-annee { display: none; }

.jours-semaine,
.grille {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.jours-semaine div {
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--texte-doux);
  padding: 4px 0 12px;
}

.grille { grid-auto-rows: minmax(clamp(64px, 11vh, 104px), auto); gap: 4px; }

.jour {
  position: relative;
  border-radius: calc(var(--rayon) - 6px);
  padding: 8px 8px 6px;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
  container-type: inline-size;
  transition: background 0.25s ease, border-color 0.25s ease;
}
@container (max-width: 96px) { .pilule .t { display: none; } }
.jour:hover { background: rgba(255, 255, 255, 0.45); }
.jour.hors-mois { opacity: 0.38; }
.jour.selection { background: var(--carte-forte); border-color: var(--accent-clair); }

.jour .numero {
  font-family: var(--police-titre);
  font-size: 1.15rem;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  margin: -3px 0 2px -3px;
}
.jour.aujourdhui .numero { background: var(--aujourdhui); color: #fff; }

.pilule {
  display: block;
  font-size: 0.72rem;
  line-height: 1.25;
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: color-mix(in srgb, var(--c) 22%, transparent);
  border-left: 3px solid var(--c);
}
[data-theme="zen"] .pilule { border-left: none; border-radius: 999px; padding: 2px 8px; }
.plus { font-size: 0.7rem; color: var(--texte-doux); padding-left: 4px; }

.points { display: none; gap: 3px; justify-content: center; }
.points i { width: 5px; height: 5px; border-radius: 50%; background: var(--c); }

/* ───────────── Vue annuelle ───────────── */
.vue-annee {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px 18px;
}

.mini-mois {
  padding: 10px 10px 12px;
  border-radius: calc(var(--rayon) - 4px);
  transition: background 0.25s ease;
}
.mini-mois.courant { background: color-mix(in srgb, var(--accent-clair) 30%, transparent); }

.mini-titre {
  border: none;
  background: none;
  padding: 2px 4px 8px;
  font-family: var(--police-titre);
  font-size: 1.25rem;
  letter-spacing: var(--titre-espacement);
  text-transform: capitalize;
  color: var(--texte);
}
.mini-titre:hover { color: var(--accent); }

.mini-grille {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.mini-entete { font-size: 0.62rem; color: var(--texte-doux); text-transform: uppercase; padding-bottom: 3px; }

.mini-jour {
  aspect-ratio: 1;
  border: none;
  background: none;
  border-radius: 50%;
  font-size: 0.74rem;
  padding: 0;
  position: relative;
  color: var(--texte);
}
.mini-jour:hover { background: rgba(255, 255, 255, 0.6); }
.mini-jour.occupe { background: color-mix(in srgb, var(--c) 30%, transparent); font-weight: 500; }
.mini-jour.aujourdhui { background: var(--aujourdhui); color: #fff; }
.mini-jour.selection { box-shadow: inset 0 0 0 1.5px var(--accent); }

/* ───────────── Colonne : journée + tâches ───────────── */
.colonne {
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 2vw, 24px);
  position: sticky;
  top: 16px;
}

.journee, .bloc-taches { padding: 24px 22px; display: flex; flex-direction: column; }
.journee { max-height: 52vh; }
.bloc-taches { max-height: 40vh; }

.journee-entete { padding-bottom: 16px; border-bottom: 1px solid var(--ligne); margin-bottom: 14px; }
.journee-nom, .taches-titre {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
}
.journee-date {
  font-family: var(--police-titre);
  font-size: 2rem;
  font-weight: var(--titre-poids);
  letter-spacing: var(--titre-espacement);
}

.taches-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ligne);
  margin-bottom: 12px;
}
.taches-compte {
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  display: grid;
  place-items: center;
}
.taches-compte:empty { display: none; }

.liste { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }

.evenement {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  padding: 12px 14px;
  border-radius: calc(var(--rayon) - 4px);
  background: color-mix(in srgb, var(--c) 14%, var(--carte-forte));
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.evenement .heure { font-size: 0.85rem; color: var(--texte-doux); line-height: 1.35; }
.evenement .heure b { display: block; color: var(--texte); font-weight: 500; font-size: 0.95rem; }
.evenement .nom { font-weight: 500; }
.details { font-size: 0.82rem; color: var(--texte-doux); margin-top: 2px; }

.tache {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px 4px;
  border-bottom: 1px dashed var(--ligne);
}
.tache:last-child { border-bottom: none; }
.coche {
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  background: transparent;
  position: relative;
  padding: 0;
}
.tache.faite .coche { background: var(--accent); }
.tache.faite .coche::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 3px;
  width: 6px;
  height: 11px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.tache.faite .tache-texte { text-decoration: line-through; color: var(--texte-doux); }
.tache.faite { opacity: 0.6; }
.tache.retard .details { color: var(--accent-2); }

.nouveau { animation: eclat 2.4s ease; }
@keyframes eclat {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); transform: scale(1.02); }
  100% { box-shadow: 0 0 0 14px transparent; transform: scale(1); }
}

.vide {
  color: var(--texte-doux);
  font-style: italic;
  font-family: var(--police-titre);
  font-size: 1.15rem;
  padding: 18px 4px;
  text-align: center;
}
.vide.petit { font-size: 1rem; padding: 8px 4px; }

/* ───────────── Voix ───────────── */
.voix {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 16px max(26px, env(safe-area-inset-bottom));
  gap: 10px;
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--fond-2) 92%, transparent) 38%);
}

.sous-titres { min-height: 3.4em; max-width: 720px; text-align: center; }
.sous-titres p { margin: 0; }
.dit-utilisateur { font-size: 0.9rem; color: var(--texte-doux); font-style: italic; }
.dit-assistant {
  font-family: var(--police-titre);
  font-size: 1.25rem;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.micro {
  --niveau: 0;
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--accent-2)));
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 14px 34px -12px color-mix(in srgb, var(--accent) 80%, transparent);
  transition: transform 0.25s ease, background 0.6s ease;
}
.micro:hover { transform: scale(1.04); }
.micro svg { width: 34px; height: 34px; fill: currentColor; position: relative; z-index: 2; }

.micro .halo,
.micro .anneau {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}
.micro .halo {
  background: var(--accent);
  opacity: 0;
  transform: scale(calc(1 + var(--niveau) * 0.9));
  transition: transform 0.08s linear, opacity 0.4s ease;
}
.micro .anneau { border: 1px solid var(--accent); opacity: 0; }

body.ecoute .micro .halo,
body.parle .micro .halo { opacity: 0.22; }
body.connexion .micro .anneau { animation: tourne 1.4s ease-in-out infinite; opacity: 1; border-color: var(--accent) transparent; }
body.ecoute .micro .anneau { animation: respire 3s ease-in-out infinite; }
body.parle .micro { background: linear-gradient(145deg, var(--accent-2), var(--accent)); }
body.erreur .micro { background: #b98282; }

@keyframes respire { 0%, 100% { transform: scale(1); opacity: 0.5; } 50% { transform: scale(1.35); opacity: 0; } }
@keyframes tourne { to { transform: rotate(360deg) scale(1.18); } }

.etat { margin: 0; font-size: 0.78rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--texte-doux); }

/* ───────────── Rappels ───────────── */
.rappels {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 20;
}
.rappel {
  background: var(--carte-forte);
  border: 1px solid var(--accent-clair);
  border-radius: var(--rayon);
  box-shadow: 0 24px 60px -20px rgba(60, 40, 30, 0.45);
  padding: 16px 18px;
  animation: descend 0.5s ease;
}
.rappel-titre { font-size: 0.75rem; letter-spacing: 0.25em; text-transform: uppercase; color: var(--accent); }
.rappel-texte { font-family: var(--police-titre); font-size: 1.2rem; margin: 6px 0 12px; line-height: 1.3; }
.rappel-ok {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 8px 20px;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}
@keyframes descend { from { opacity: 0; transform: translateY(-14px); } }

/* ───────────── Réveil ───────────── */
.sonnerie {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--accent-clair) 70%, var(--fond)) 0%, var(--fond) 70%);
  animation: apparait 0.8s ease;
}
.sonnerie-cercle {
  position: absolute;
  width: min(70vw, 420px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--accent);
  top: 50%;
  left: 50%;
  translate: -50% -60%;
  animation: respire 4s ease-in-out infinite;
  pointer-events: none;
}
.sonnerie-heure {
  font-family: var(--police-titre);
  font-size: clamp(4.5rem, 18vw, 8rem);
  font-weight: var(--titre-poids);
  line-height: 1;
  letter-spacing: var(--titre-espacement);
}
.sonnerie-libelle { font-family: var(--police-titre); font-size: 1.5rem; max-width: 520px; }
.sonnerie-musique { color: var(--texte-doux); font-size: 0.9rem; letter-spacing: 0.1em; }
.sonnerie-boutons { display: flex; gap: 14px; margin-top: 34px; flex-wrap: wrap; justify-content: center; }
.sonnerie-boutons button {
  min-width: 170px;
  padding: 18px 26px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--carte-forte);
  font-size: 1.05rem;
}
.sonnerie-boutons .principal { background: var(--accent); color: #fff; }
@keyframes apparait { from { opacity: 0; } }

/* ───────────── Code d'accès (version en ligne) ───────────── */
.code-acces {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--fond) 88%, transparent);
  backdrop-filter: blur(10px);
}
.code-carte {
  width: min(360px, 100%);
  background: var(--carte-forte);
  border: 1px solid var(--ligne);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.code-titre { font-family: var(--police-titre); font-size: 1.8rem; letter-spacing: var(--titre-espacement); }
.code-carte p { margin: 0; color: var(--texte-doux); font-size: 0.95rem; }
.code-carte input {
  font: inherit;
  font-size: 1.1rem;
  text-align: center;
  padding: 14px;
  border-radius: 999px;
  border: 1px solid var(--accent-clair);
  background: var(--fond);
  color: var(--texte);
}
.code-carte input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.code-carte button {
  border: none;
  border-radius: 999px;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  letter-spacing: 0.08em;
}

/* ───────────── Smartphone ───────────── */
@media (max-width: 860px) {
  .contenu { grid-template-columns: 1fr; }
  .colonne { position: static; }
  .journee, .bloc-taches { max-height: none; }
  .liste { overflow: visible; }
}

@media (max-width: 600px) {
  .entete { flex-direction: column; align-items: stretch; padding-top: max(22px, env(safe-area-inset-top)); gap: 14px; }
  .titre { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  .titre h1 { font-size: 2.4rem; order: 0; }
  .surtitre { order: 1; margin: 0; }
  .nav { justify-content: space-between; }
  .bouton-vue { flex: 1; margin-left: 0; }
  .alarme-suivante { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 16px; margin: 0; }
  .entete { position: relative; }

  .calendrier { padding: 10px 6px; }
  .grille { grid-auto-rows: minmax(54px, auto); gap: 2px; }
  .jour { padding: 5px 2px; align-items: center; }
  .jour .numero { margin: 0; font-size: 1.05rem; }
  .jour .pilule, .jour .plus { display: none; }
  .jour .points { display: flex; }
  .jours-semaine div { letter-spacing: 0.08em; font-size: 0.66rem; }

  .vue-annee { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .mini-mois { padding: 6px 4px 8px; }
  .mini-titre { font-size: 1.05rem; padding-bottom: 4px; }
  .mini-jour { font-size: 0.66rem; }

  .journee, .bloc-taches { padding: 20px 18px; }
  .journee-date { font-size: 1.7rem; }
  .micro { width: 76px; height: 76px; }
  .dit-assistant { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
