/* ============================================================
   Météo Intérieure — styles de base (mobile-first)
   Les adaptations par taille d'écran vivent dans responsive.css
   ============================================================ */

/* ── Thèmes (palettes de couleurs) ─────────────────────────── */

:root {
  /* Palette par défaut : Aube pastel (light) */
  color-scheme: light;
  --bg: #FAF7F2;
  --blob-1: #FFD9E8;
  --blob-2: #D3E7FF;
  --surface: #FFFFFF;
  --surface-2: #F3EFE8;
  --line: rgba(90, 82, 120, 0.14);
  --text: #4A4458;
  --text-soft: #8B849E;
  --primary: #8FB4DC;
  --primary-strong: #6E9AC9;
  --accent: #F2B8C6;
  --ok: #DFF0E5;
  --ok-strong: #5F9E78;
  --danger: #D96C6C;
  --danger-soft: #F8E4E4;
  --shadow-card: 0 6px 24px rgba(70, 60, 110, 0.08);
  --radius: 20px;
  --radius-sm: 12px;
  --tabbar-h: 64px;
}

[data-theme="pastel-dark"] {
  color-scheme: dark;
  --bg: #242138;
  --blob-1: #3D3260;
  --blob-2: #2C3E5C;
  --surface: #2F2B48;
  --surface-2: #3A3558;
  --line: rgba(230, 225, 255, 0.14);
  --text: #EDE9F7;
  --text-soft: #A9A3C4;
  --primary: #7FA8DC;
  --primary-strong: #94BCEC;
  --accent: #E2A8C8;
  --ok: #2F4A3C;
  --ok-strong: #8FD0A8;
  --danger: #E89A9A;
  --danger-soft: #4A3038;
  --shadow-card: 0 6px 24px rgba(0, 0, 0, 0.35);
}

[data-theme="sauge"] {
  color-scheme: light;
  --bg: #F2F6EF;
  --blob-1: #D9E8CE;
  --blob-2: #C7E2DA;
  --surface: #FFFFFF;
  --surface-2: #E9F0E4;
  --line: rgba(70, 90, 70, 0.15);
  --text: #40503F;
  --text-soft: #7E9080;
  --primary: #8FB79A;
  --primary-strong: #6FA080;
  --accent: #DCC08F;
  --ok: #E0F0E4;
  --ok-strong: #5F9E78;
  --danger: #CC7A6E;
  --danger-soft: #F5E3DF;
}

[data-theme="lavande"] {
  color-scheme: light;
  --bg: #F6F2FA;
  --blob-1: #E4D5F5;
  --blob-2: #F5D8E8;
  --surface: #FFFFFF;
  --surface-2: #EFE8F6;
  --line: rgba(100, 80, 130, 0.15);
  --text: #4C4160;
  --text-soft: #93879F;
  --primary: #A99BD1;
  --primary-strong: #8F7FC0;
  --accent: #E7A8CB;
  --ok: #E4F0E8;
  --ok-strong: #6FA080;
  --danger: #D97B8A;
  --danger-soft: #F8E4E9;
}

[data-theme="ocean"] {
  color-scheme: dark;
  --bg: #1C2B33;
  --blob-1: #234A50;
  --blob-2: #1F3A52;
  --surface: #24363F;
  --surface-2: #2C424D;
  --line: rgba(200, 230, 235, 0.14);
  --text: #E4EFF2;
  --text-soft: #9DB8BF;
  --primary: #6FB4B9;
  --primary-strong: #8ECDD2;
  --accent: #E8C48F;
  --ok: #27443A;
  --ok-strong: #85CBA5;
  --danger: #E39A94;
  --danger-soft: #4A3434;
  --shadow-card: 0 6px 24px rgba(0, 0, 0, 0.4);
}

/* ── Base ───────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
html { height: 100%; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}

/* Fond zen : deux halos pastel qui dérivent lentement */
body::before, body::after {
  content: "";
  position: fixed;
  z-index: -1;
  width: 48vmax;
  height: 48vmax;
  border-radius: 50%;
  filter: blur(64px);
  opacity: 0.55;
  pointer-events: none;
  transition: background 0.6s ease;
}
body::before {
  background: var(--blob-1);
  top: -12vmax;
  left: -12vmax;
  animation: blob-float-1 26s ease-in-out infinite alternate;
}
body::after {
  background: var(--blob-2);
  bottom: -14vmax;
  right: -12vmax;
  animation: blob-float-2 32s ease-in-out infinite alternate;
}
@keyframes blob-float-1 { to { transform: translate(6vmax, 5vmax) scale(1.08); } }
@keyframes blob-float-2 { to { transform: translate(-5vmax, -6vmax) scale(1.12); } }

.hidden { display: none !important; }
.muted { color: var(--text-soft); font-size: 14px; }
.no-scroll { overflow: hidden; }
.svg-defs { position: absolute; }

h1, h2, h3 { line-height: 1.3; }

/* ── Boutons & champs ───────────────────────────────────────── */

.btn {
  min-height: 44px;
  padding: 12px 20px;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(60, 80, 120, 0.18);
}
.btn-primary:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(60, 80, 120, 0.24); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn-big { font-size: 18px; padding: 16px 32px; }
.btn-icon {
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
}

input[type="text"], input[type="password"], input[type="date"], select, textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px; /* évite le zoom iOS */
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
}
textarea { resize: vertical; min-height: 56px; line-height: 1.5; }
input:focus-visible, select:focus-visible, .btn:focus-visible, button:focus-visible {
  outline: 2px solid var(--primary-strong);
  outline-offset: 2px;
}

.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; text-align: left; }
.field > span { font-size: 14px; font-weight: 600; color: var(--text-soft); }
.check-row { display: flex; align-items: center; gap: 8px; margin: 12px 0 16px; font-size: 15px; cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--primary-strong); flex-shrink: 0; }
.form-error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }

/* ── Écran de connexion ─────────────────────────────────────── */

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 24px;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow-card);
  text-align: center;
  animation: pop-in 0.5s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.login-logo svg { width: 84px; height: 84px; }
.login-card h1 { font-size: 24px; margin: 8px 0 4px; }
.login-tagline { color: var(--text-soft); margin: 0 0 24px; font-size: 15px; }
.login-error { color: var(--danger); font-size: 14px; margin: 12px 0 0; }
.login-invite-note { margin: 20px 0 0; line-height: 1.6; }

.user-id-big {
  margin: 8px 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--primary-strong);
}

/* ── Structure de l'app ─────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand-icon svg { width: 34px; height: 34px; display: block; }
.greeting {
  min-height: 44px;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}
.greeting:disabled { cursor: default; box-shadow: none; opacity: 0.75; }

.views {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px calc(var(--tabbar-h) + 24px);
}
.view { animation: fade-up 0.35s ease; }
.view-title { font-size: 22px; font-weight: 700; margin: 8px 0 16px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 17px; }

.empty-state {
  text-align: center;
  color: var(--text-soft);
  padding: 32px 16px;
  font-size: 15px;
  line-height: 1.7;
}

/* ── Barre d'onglets (mobile : fixée en bas) ────────────────── */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  border: none;
  background: none;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.2s ease;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--primary-strong); font-weight: 600; }
.tab.active::after {
  content: "";
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: var(--primary-strong);
}

/* ── Icônes météo animées ───────────────────────────────────── */

.wicon { display: block; }
.sun-rays, .sun-rays-sm {
  transform-box: fill-box;
  transform-origin: center;
  animation: spin 26s linear infinite;
}
.drift { animation: drift 7s ease-in-out infinite alternate; }
.drift-slow { animation: drift 10s ease-in-out infinite alternate; }
.rain line { animation: rainfall 1.4s ease-in infinite; }
.rain line:nth-child(2) { animation-delay: 0.35s; }
.rain line:nth-child(3) { animation-delay: 0.7s; }
.rain line:nth-child(4) { animation-delay: 1.05s; }
.bolt {
  transform-box: fill-box;
  transform-origin: center;
  animation: flash 3.2s ease-in-out infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes drift { from { transform: translateX(-1.5px); } to { transform: translateX(2px); } }
@keyframes rainfall {
  0% { transform: translateY(-2px); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translateY(7px); opacity: 0; }
}
@keyframes flash {
  0%, 40%, 60%, 100% { opacity: 1; }
  46% { opacity: 0.25; }
  50% { opacity: 1; }
  54% { opacity: 0.45; }
}

/* ── Jauge barométrique ─────────────────────────────────────── */

.gauge-wrap { text-align: center; }
.gauge { width: min(100%, 340px); height: auto; display: block; margin: 0 auto; }
.gauge-track { fill: none; stroke: var(--surface-2); stroke-width: 16; stroke-linecap: round; }
.gauge-arc { fill: none; stroke-width: 16; stroke-linecap: round; }
.gauge-tick { stroke: rgba(255, 255, 255, 0.85); stroke-width: 3; stroke-linecap: round; }
.gauge-needle polygon { fill: var(--text); }
.gauge-needle .gauge-hub { fill: var(--text); }
.gauge-needle .gauge-hub-dot { fill: var(--surface); }
.gauge-needle {
  transform-box: view-box;
  transform-origin: 110px 106px;
  transition: transform 1.1s cubic-bezier(0.3, 1.35, 0.5, 1), opacity 0.4s ease;
}
.gauge-needle.idle { opacity: 0.35; }
.gauge.interactive { cursor: pointer; touch-action: none; }
.gauge.dragging .gauge-needle { transition: transform 0.15s ease, opacity 0.4s ease; }
.gauge-caption { margin: 8px 0 0; font-size: 17px; font-weight: 700; color: var(--text); }
.gauge-subcaption { margin: 0; font-size: 13px; color: var(--text-soft); min-height: 20px; }

.mood-hint { text-align: center; color: var(--text-soft); font-size: 15px; margin: 12px 0 0; }
.mood-hint strong { color: var(--primary-strong); }

/* ── Tuiles météo ───────────────────────────────────────────── */

/* Mobile : les 5 tuiles tiennent sur une seule ligne, sans scroll */
.mood-tiles {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 16px 0 24px;
}
/* Cartes aquarelle : illustration + libellé + pastille numérotée
   (visuels extraits des mockups, cf. _ressources/) */
.mood-tile {
  display: flex;
  flex-direction: column;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  box-shadow: var(--shadow-card);
  font-family: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.4s ease, opacity 0.4s ease;
}
.tile-img { display: block; width: 100%; aspect-ratio: 1 / 0.92; }
.tile-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile-label {
  padding: 6px 2px 0;
  font-size: clamp(9px, 2.9vw, 15px);
  font-weight: 700;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
  overflow-wrap: normal;
}
.tile-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin: 3px auto 8px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  color: #FFFFFF;
}
.tile-num.n1 { background: #33415E; }
.tile-num.n2 { background: #5B87B5; }
.tile-num.n3 { background: #A8CBE8; color: #33415E; }
.tile-num.n4 { background: #F2C94C; color: #6E5312; }
.tile-num.n5 { background: #EE8F2C; }
.mood-tile:not(:disabled):hover { transform: translateY(-4px) scale(1.02); }
.mood-tile:not(:disabled):active { transform: scale(0.97); }
.mood-tile.selected { outline: 3px solid var(--primary-strong); outline-offset: 1px; transform: translateY(-2px); }
.mood-tile:disabled { filter: grayscale(0.8); opacity: 0.55; cursor: default; box-shadow: none; }
.mood-tile.selected:disabled { filter: none; opacity: 1; transform: none; box-shadow: var(--shadow-card); }

.mood-confirm { max-width: 480px; margin: 0 auto 24px; }

/* ── Phénomènes météo (petites tuiles optionnelles, cumulables) ──── */
.phenomena-picker { margin-bottom: 16px; }
.phenomena-hint {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  text-align: center;
}
/* Un maximum de tuiles par ligne pour limiter le scroll avant de valider */
.phenomena-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 6px;
}
.phenom-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 0 0 4px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.phenom-img { display: block; width: 100%; aspect-ratio: 1 / 1.1; overflow: hidden; }
.phenom-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.phenom-label {
  padding: 0 2px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--text);
  text-align: center;
  overflow-wrap: anywhere;
}
.phenom-tile:hover { transform: translateY(-2px); }
.phenom-tile:active { transform: scale(0.96); }
.phenom-tile.selected {
  border-color: var(--primary-strong);
  box-shadow: 0 0 0 2px var(--primary), var(--shadow-card);
}
/* Pastille ✓ sur une tuile cochée */
.phenom-tile.selected .phenom-img { position: relative; }
.phenom-tile.selected .phenom-img::after {
  content: "✓";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary-strong);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
}

/* ── Galerie de réconfort ───────────────────────────────────── */

.comfort-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.comfort-item { position: relative; margin: 0; }
.comfort-view {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
}
.comfort-view img { display: block; width: 100%; height: 100%; object-fit: cover; }
.comfort-unpin {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(25, 25, 40, 0.55);
  color: #FFFFFF;
  font-size: 14px;
  cursor: pointer;
  backdrop-filter: blur(2px);
}
.comfort-add {
  aspect-ratio: 1;
  border: 2px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 28px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.comfort-add:hover { background: var(--ok); }

.mood-support {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  line-height: 1.6;
  text-align: left;
  margin: 12px 0 0;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  margin: 8px 0 4px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
}
.dz-preview { max-width: 100%; max-height: 220px; border-radius: var(--radius-sm); object-fit: contain; }
.dz-hint { color: var(--text-soft); font-size: 14px; }

.modal.lightbox { background: transparent; box-shadow: none; padding: 8px; max-width: min(96vw, 760px); }
.lightbox-img { display: block; width: 100%; max-height: 80vh; object-fit: contain; border-radius: 16px; }

/* ── Pilulier (accueil) ─────────────────────────────────────── */

.med-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 16px;
  background: var(--surface-2);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.med-item.late { background: var(--danger-soft); box-shadow: inset 4px 0 0 var(--danger); }
.med-item.late .med-time { color: var(--danger); font-weight: 700; }
.med-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.med-name { font-weight: 600; }
.med-dose { font-size: 13px; color: var(--text-soft); }
.med-time { font-size: 14px; color: var(--text-soft); white-space: nowrap; }
.med-check {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--ok-strong);
  background: var(--surface);
  color: var(--ok-strong);
  font-size: 22px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.med-check:hover { background: var(--ok); transform: scale(1.06); }
.med-item.taken { opacity: 0; transform: translateX(32px); }
.med-item.taken .med-name { text-decoration: line-through; }
.meds-done { color: var(--ok-strong); font-weight: 600; margin: 4px 0; }
.med-upcoming {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  color: var(--text-soft);
  font-size: 14px;
}
.meds-sub { margin: 12px 0 4px; font-size: 13px; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.4px; }

/* ── Pilulier (réglages) ────────────────────────────────────── */

.med-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.med-row:last-of-type { border-bottom: none; }
.med-row-info { min-width: 0; }
.med-row-times { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.med-row-actions { display: flex; gap: 8px; flex-shrink: 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
}
.chip button {
  border: none;
  background: none;
  color: var(--text-soft);
  font-size: 15px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.mf-times { display: flex; gap: 6px; flex-wrap: wrap; min-height: 32px; margin-bottom: 8px; }
.mf-add { display: flex; gap: 8px; }
.mf-add select { flex: 1; }
#add-med { margin-top: 12px; }

/* ── Administration ──────────────────────────────────────────── */

.admin-card { box-shadow: var(--shadow-card), inset 3px 0 0 var(--danger); }
.purge-range { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }

.user-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.user-info { display: flex; flex-direction: column; min-width: 0; text-align: left; flex: 1; }
.user-actions { display: flex; gap: 8px; flex-shrink: 0; }
.admin-invite { margin-bottom: 16px; }

.trends-banner {
  margin: 0 0 12px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* Session admin : pas de données personnelles → on masque l'inutile */
.admin-mode .tab[data-view="relax"] { display: none; }
.admin-mode .card-profile,
.admin-mode .card-password,
.admin-mode .card-refresh,
.admin-mode .card-theme,
.admin-mode .card-notifs,
.admin-mode .card-pillbox { display: none; }

/* ── Notifications (Réglages) ───────────────────────────────── */

.notif-prefs { margin-top: 12px; }
.notif-prefs .check-row { margin-bottom: 8px; }
.notif-quiet { margin: 8px 0 0; font-size: 13px; }
#notif-status, #admin-notif-status { margin-bottom: 12px; }

/* ── Tendances : graphique & stats ──────────────────────────── */

.period-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  background: var(--surface);
  border-radius: 999px;
  box-shadow: var(--shadow-card);
}
.period-tab {
  flex: 1;
  min-height: 44px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
}
.period-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #FFFFFF;
}

.chart-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.chart-nav-label { flex: 1; text-align: center; font-size: 14px; font-weight: 600; color: var(--text-soft); }
.btn-icon:disabled { opacity: 0.4; cursor: default; }

.chart-card { overflow-x: auto; }
#chart { min-width: 480px; }
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-dasharray: 3 5; }
.chart-line { fill: none; stroke: var(--primary-strong); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: url(#g-area); }
.area-stop-top { stop-color: var(--primary); stop-opacity: 0.3; }
.area-stop-bottom { stop-color: var(--primary); stop-opacity: 0; }
.chart-dot { fill: var(--surface); stroke: var(--primary-strong); stroke-width: 2.5; cursor: pointer; }
.chart-dot.commented { fill: var(--accent); }
.chart-label { fill: var(--text-soft); font-size: 13px; font-family: inherit; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; margin-bottom: 0; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--primary-strong); line-height: 1.2; }
.stat-ico svg { width: 48px; height: 48px; }
.stat-label { font-size: 13px; color: var(--text-soft); }

.dist-row {
  display: grid;
  grid-template-columns: 28px minmax(76px, auto) 1fr 44px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.dist-ico { width: 26px; height: 26px; }
.dist-label { font-size: 14px; }
.dist-bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.dist-fill { height: 100%; border-radius: 5px; transition: width 0.8s cubic-bezier(0.2, 0.8, 0.3, 1); }
.dist-fill.m1 { background: #8A93B8; }
.dist-fill.m2 { background: #8FB3D8; }
.dist-fill.m3 { background: #AEB9CC; }
.dist-fill.m4 { background: #F0CE8C; }
.dist-fill.m5 { background: #FFC163; }
.dist-pct { font-size: 13px; text-align: right; color: var(--text-soft); }

/* Statistiques des phénomènes météo (Tendances) */
.phenom-stat-row {
  display: grid;
  grid-template-columns: 32px minmax(84px, auto) 1fr 40px;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.phenom-stat-img { width: 32px; height: 32px; border-radius: 8px; overflow: hidden; }
.phenom-stat-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.phenom-stat-label { font-size: 14px; }
.phenom-stat-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--primary-strong);
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.phenom-stat-count { font-size: 13px; text-align: right; color: var(--text-soft); }

.word-cloud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 4px 12px;
  padding: 8px 0 4px;
}
.word-cloud span { line-height: 1.3; font-weight: 600; cursor: default; }
.word-cloud .wc-0 { color: var(--primary-strong); }
.word-cloud .wc-1 { color: var(--text); }
.word-cloud .wc-2 { color: var(--ok-strong); }

/* ── Détente ────────────────────────────────────────────────── */

.relax-moods { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 8px 0 16px; }
.relax-mood {
  width: 56px;
  height: 56px;
  padding: 8px;
  border: none;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.relax-mood { padding: 4px; overflow: hidden; }
.relax-mood img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.relax-mood.active { opacity: 1; outline: 2px solid var(--primary-strong); transform: translateY(-2px); }
.relax-intro { text-align: center; color: var(--text-soft); margin: 0 0 16px; }
.exo-cards { display: grid; gap: 12px; }
.exo-card h3 { margin-bottom: 4px; }
.exo-card p { color: var(--text-soft); font-size: 14px; margin: 0 0 12px; }
.exo-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ── Lecteur d'exercice (plein écran) ───────────────────────── */

.exo-player {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  animation: fade-in 0.3s ease;
}
.exo-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}
.exo-title { font-weight: 700; font-size: 18px; }
.exo-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  overflow-y: auto;
}
.exo-intro, .exo-end {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 420px;
  text-align: center;
  animation: fade-up 0.4s ease;
}
.exo-desc { font-size: 17px; margin: 0; }
.exo-duration { color: var(--text-soft); font-size: 14px; margin: 0; }
.exo-end-ico { font-size: 44px; }

.breath-wrap { display: flex; flex-direction: column; align-items: center; gap: 24px; width: 100%; }
.breath-circle {
  width: min(56vw, 240px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--primary), var(--primary-strong));
  box-shadow: 0 0 64px rgba(126, 158, 206, 0.45);
  will-change: transform;
}
.breath-box {
  position: relative;
  width: min(56vw, 220px);
  aspect-ratio: 1;
  border: 3px solid var(--primary-strong);
  border-radius: 28px;
}
.breath-dot {
  position: absolute;
  left: -9px;
  top: -9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent);
  will-change: transform;
}
.breath-label { font-size: 28px; font-weight: 600; min-height: 42px; }
.breath-count { font-size: 44px; font-weight: 300; color: var(--text-soft); line-height: 1; }

.exo-progress {
  width: min(80%, 320px);
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}
.exo-progress-fill { height: 100%; width: 0; border-radius: 2px; background: var(--primary-strong); }

.steps-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: 460px;
  text-align: center;
}
.step-text { font-size: 21px; line-height: 1.6; min-height: 100px; display: flex; align-items: center; justify-content: center; }
.step-count { font-size: 13px; }
.fade-in { animation: fade-up 0.6s ease; }

.scene {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: min(44vh, 340px);
  border-radius: 24px;
  overflow: hidden;
}
.scene-rain { background: linear-gradient(180deg, #5C6B94, #3D4768); }
.drop {
  position: absolute;
  top: -10%;
  width: 2.5px;
  height: 16px;
  border-radius: 2px;
  background: rgba(215, 232, 255, 0.75);
  animation: fall linear infinite;
}
@keyframes fall {
  0% { top: -8%; opacity: 0; }
  12% { opacity: 0.9; }
  100% { top: 104%; opacity: 0.15; }
}
.scene-clouds { background: linear-gradient(180deg, #8FA7C9, #CBD8EC); }
.puff {
  position: absolute;
  left: -30%;
  width: 200px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0));
  animation: puff-drift linear infinite;
}
@keyframes puff-drift { from { left: -30%; } to { left: 110%; } }
.scene-sun { background: linear-gradient(180deg, #FFEBBB, #FFD07E); }
.halo {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140px;
  height: 140px;
  margin: -70px 0 0 -70px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 110, 0.95), rgba(255, 214, 110, 0) 70%);
  animation: pulse 6s ease-in-out infinite alternate;
}
@keyframes pulse { from { transform: scale(1); opacity: 0.85; } to { transform: scale(1.25); opacity: 1; } }
.rays { position: absolute; inset: 0; animation: spin 80s linear infinite; }
.ray {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44%;
  height: 10px;
  margin-top: -5px;
  border-radius: 6px;
  transform-origin: 0 50%;
  background: linear-gradient(90deg, rgba(255, 205, 100, 0.55), rgba(255, 205, 100, 0));
}
.scene-prompt { font-size: 19px; text-align: center; max-width: 440px; min-height: 60px; }

/* Carte mise en avant dans Détente quand la dernière saisie portait un Ciel noir */
.exo-card-dark {
  border: 2px solid var(--primary-strong);
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
}

/* ── Exercice « Chasser les nuages » ────────────────────────── */

.cloud-exo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}
.cloud-scene {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: min(44vh, 340px);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.cloud-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none; /* le maintien pour souffler ne doit pas faire défiler */
  cursor: pointer;
}
.cloud-phase {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(20, 22, 40, 0.45);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.cloud-prompt {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
  text-align: center;
  max-width: 460px;
  min-height: 52px;
  color: var(--text);
}

/* Bouton de souffle : cible large, réaction franche au maintien */
.blow-btn {
  min-height: 60px;
  padding: 16px 34px;
  border: none;
  border-radius: 999px;
  background: var(--primary-strong);
  color: #FFFFFF;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  box-shadow: var(--shadow-card);
  transition: transform 0.12s ease, box-shadow 0.25s ease, background 0.2s ease;
}
.blow-btn.blowing {
  transform: scale(1.06);
  background: var(--ok-strong, var(--primary-strong));
  box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.12), var(--shadow-card);
  animation: blow-pulse 0.45s ease-in-out infinite alternate;
}
@keyframes blow-pulse {
  from { transform: scale(1.04); }
  to   { transform: scale(1.09); }
}

/* ── Thèmes (réglages) ──────────────────────────────────────── */

.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme-swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}
.theme-swatch.active { border-color: var(--primary-strong); }
.theme-dots { display: flex; gap: 4px; flex-shrink: 0; }
.theme-dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }

/* ── Modales ────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(40, 35, 60, 0.4);
  backdrop-filter: blur(6px);
  animation: fade-in 0.25s ease;
}
.modal-overlay.closing { animation: fade-out 0.2s ease forwards; }
.modal {
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 24px;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  text-align: center;
  animation: pop-in 0.35s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.modal h3 { margin: 0 0 12px; font-size: 20px; }
.modal-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.mood-modal-img {
  width: 180px;
  max-width: 70%;
  aspect-ratio: 1 / 0.9;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  margin: 0 auto 8px;
}
.name-hello { font-size: 40px; }

/* ── Toasts ─────────────────────────────────────────────────── */

#toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px));
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: calc(100vw - 32px);
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  pointer-events: auto;
  animation: fade-up 0.3s ease;
}
.toast.out { opacity: 0; transition: opacity 0.25s ease; }
.toast-action {
  min-height: 32px;
  padding: 4px 8px;
  border: none;
  background: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

/* ── Animations génériques ──────────────────────────────────── */

@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(12px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.85); } }

/* ── Accessibilité : mouvement réduit ───────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
