:root {
  --bg: #0E0E10;
  --surface: #1B1B1F;
  --border: #2C2C33;
  --text: #F5F5F0;
  --text-2: #8D8D96;
  --text-3: #6B6B74;
  --action: #D4FF3A;
  --premium: #FFC24B;
  --urgency: #FF7A3D;
  --on-color: #0E0E10;
  /* Pas un token de la charte (section 2 du brief) : rôle distinct (erreur
     réseau/génération, .error-text uniquement), jamais réutilisé pour la
     série en danger, seul rôle restant de --urgency depuis le retrait du
     timer (V2.1, changement 1). */
  --error: #FF5C5C;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

#app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}

/* Thème unique (sombre) : le splash partage désormais exactement --bg, plus
   besoin d'une palette isolée ni d'un correctif runtime du theme-color. */
#splash {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease;
}

#splash img {
  width: min(70vw, 360px);
}

#splash.hidden {
  opacity: 0;
  pointer-events: none;
}

.app-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
  font-size: 0.75rem;
  color: var(--text-2);
}

.app-footer a {
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-link-button {
  background: none;
  border: none;
  font: inherit;
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
  cursor: pointer;
}

/* Langue active (V2.1, changement 3) : plate, non soulignée — l'autre langue
   reste un vrai lien cliquable, seule façon de la distinguer sans dupliquer
   un état "sélectionné" à traduire lui-même. */
.footer-link-button.active {
  color: var(--text);
  text-decoration: none;
  cursor: default;
}

/* Corrige le bug du double point médian : c'est tout le groupe séparateur +
   bouton qui se masque ensemble (jamais le bouton seul), donc aucun " · "
   orphelin ne peut rester collé à son voisin une fois l'app installée. */
.footer-install-group.hidden {
  display: none;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 32px 24px;
  animation: fade-in 0.35s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Ligne du haut de l'écran de saisie : bouton Sons à gauche, pastille de
   série à droite (phase 3) — réutilise .shell-header (flex, space-between). */
.top-bar {
  width: 100%;
  max-width: 420px;
  margin-bottom: 4px;
}

.sound-button {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-2);
  padding: 0;
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  border: 1px solid var(--urgency);
  color: var(--urgency);
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}

.streak-badge.calm {
  border-color: var(--border);
  color: var(--text-2);
}

.install-banner {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 16px 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  animation: fade-in 0.35s ease;
}

.install-banner-text {
  flex: 1;
  min-width: 0;
}

.install-banner-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.install-banner-subtitle {
  font-size: 0.82rem;
  color: var(--text-2);
  margin-top: 2px;
}

.install-banner-button {
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--action);
  color: var(--on-color);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}

.install-banner-dismiss {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
}

.spacer {
  flex: 1;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-2);
  text-align: center;
  margin-top: 8px;
}

.quota-text {
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
  margin-bottom: 8px;
}

/* Champs auto (saisie tâche + contexte, écran 1) — textarea à hauteur
   automatique (1 à 3 lignes) : plus aucun placeholder tronqué, quelle que
   soit sa longueur (correctif section 10). */
.field-textarea {
  width: 100%;
  max-width: 420px;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.35;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  resize: none;
  overflow: hidden;
  min-height: 46px;
  max-height: calc(1.35em * 3 + 24px + 3px);
  transition: border-color 0.2s ease;
}

.field-textarea:focus {
  outline: none;
  border-color: var(--text);
}

.field-textarea::placeholder {
  color: var(--text-3);
}

/* Champs restants à saisie unique (email, code à 6 chiffres, pseudo…) —
   inchangés dans leur rôle, seulement retonisés. */
input[type="text"] {
  width: 100%;
  max-width: 420px;
  font-size: 1.05rem;
  padding: 16px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--text);
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* Filet de sécurité global : une icône SVG sans width/height ne doit jamais
 * pouvoir gonfler un bouton (voir le bug du bouton "Fait" — checkmarkSvg()
 * sans taille explicite s'est retrouvée dimensionnée ~500px dans certains
 * contextes). Les icônes fixent aussi leur propre taille côté JS ; ceci est
 * la seconde ligne de défense, pas la seule. */
button svg {
  flex-shrink: 0;
}

.primary-button {
  width: 100%;
  max-width: 420px;
  height: 52px;
  font-size: 16px;
  font-weight: 500;
  padding: 0 16px;
  border-radius: 14px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--action);
  color: var(--on-color);
  transition: transform 0.15s ease, opacity 0.3s ease;
}

/* Jamais de texte blanc sur fond éclairci : --on-color reste sombre même à
   opacité réduite, contrairement à l'ancien --accent-text blanc (bug section 10). */
.primary-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.primary-button:not(:disabled):active {
  transform: scale(0.96);
}

.primary-button.premium {
  background: var(--premium);
}

.error-text {
  color: var(--error);
  font-size: 0.9rem;
  text-align: center;
  max-width: 340px;
}

.generating-text {
  color: var(--text-2);
  margin-top: 18px;
  font-size: 0.95rem;
}

.generating-title {
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  margin-bottom: 14px;
}

.progress-bar-track {
  width: 100%;
  max-width: 280px;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 40%;
  border-radius: 3px;
  background: var(--text);
  animation: progress-sweep 1.3s ease-in-out infinite;
}

@keyframes progress-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

.upsell-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--premium);
  color: var(--premium);
  border-radius: 12px;
  padding: 9px 10px;
  font-size: 13px;
  text-align: center;
  background: none;
  width: 100%;
  max-width: 280px;
}

/* ---------- Étape en cours ---------- */

.progress-segments {
  display: flex;
  gap: 4px;
  width: 100%;
  max-width: 420px;
}

.progress-segment {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  transition: background-color 300ms ease;
}

.progress-segment.filled {
  background: var(--text);
}

.step-counter-label {
  width: 100%;
  max-width: 420px;
  text-align: left;
  color: var(--text-2);
  font-size: 11px;
  margin-top: 6px;
}

.step-task-reminder {
  width: 100%;
  max-width: 420px;
  text-align: left;
  color: var(--text-3);
  font-size: 12px;
  text-decoration: line-through;
  line-height: 1.3;
  margin-top: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-text {
  font-size: clamp(32px, 9vw, 44px);
  font-weight: 500;
  text-align: left;
  line-height: 1.2;
  width: 100%;
  max-width: 420px;
  margin-top: 8px;
  transition: opacity 0.26s ease;
}

.step-text.many-lines {
  font-size: clamp(28px, 7vw, 36px);
}

.step-text.transitioning {
  opacity: 0;
}

.step-highlight {
  background: var(--action);
  color: var(--on-color);
  border-radius: 6px;
  padding: 0 6px;
}

/* ---------- Fin de session ---------- */

.completion-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--action);
  color: var(--on-color);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.completion-icon svg {
  width: 24px;
  height: 24px;
}

.completion-icon.shown {
  opacity: 1;
  animation: completion-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes completion-pop {
  0% { transform: scale(0.85); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.completion-block {
  opacity: 0;
  transition: opacity 0.4s ease 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.completion-block.shown {
  opacity: 1;
}

.completion-title {
  font-size: 20px;
  font-weight: 500;
  text-align: center;
}

.completion-subtitle {
  color: var(--text-2);
  font-size: 1.05rem;
  text-align: center;
  max-width: 320px;
}

.completion-meta {
  color: var(--text-2);
  font-size: 0.85rem;
  text-align: center;
}

.streak-line {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--urgency);
  font-size: 12px;
  font-weight: 500;
}

.share-card {
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  margin-top: 10px;
}

.share-card-brand {
  font-size: 11px;
  color: var(--text-2);
}

.share-card-line {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.25;
  margin-top: 2px;
}

.share-card-domain {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 4px;
}

.share-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  padding: 10px 16px;
  border-radius: 12px;
  z-index: 1200;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.share-toast.shown {
  opacity: 1;
}

.button-row {
  width: 100%;
  display: flex;
  justify-content: center;
}

.shell-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shell-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-2);
  padding: 8px;
}

.shell-step-counter {
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.shell-task-reminder {
  width: 100%;
  text-align: center;
  color: var(--text-2);
  font-size: 0.8rem;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-preview-card {
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
}

.task-preview-label {
  font-size: 11px;
  color: var(--text-2);
}

.task-preview-text {
  font-size: 13px;
  color: var(--text);
  margin-top: 2px;
  line-height: 1.3;
}

.field-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 420px;
  gap: 6px;
}

.field-label {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  max-width: 340px;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-2);
  text-align: center;
  max-width: 340px;
  margin-bottom: 2px;
}

.char-counter {
  width: 100%;
  max-width: 420px;
  text-align: right;
  color: var(--text-2);
  font-size: 0.78rem;
  margin-top: 4px;
}

.char-counter.hidden {
  display: none;
}

.screen-header-row {
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.screen-back {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 500;
  padding: 4px 0;
}

.history-screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 24px 32px;
  animation: fade-in 0.35s ease;
  overflow-y: auto;
}

.history-list {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.history-item-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.history-item-title {
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-date {
  font-size: 0.8rem;
  color: var(--text-2);
  margin-top: 2px;
}

.history-delete {
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text-2);
  padding: 6px;
  flex-shrink: 0;
}

.history-lock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--premium);
  font-size: 12px;
}

.onboarding-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}

.onboarding-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
}

.onboarding-dot.active {
  background: var(--text);
}

.tooltip-bubble {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 240px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.4;
  padding: 10px 30px 10px 12px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  z-index: 900;
}

.tooltip-bubble::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 20px;
  width: 10px;
  height: 10px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}

.tooltip-close {
  position: absolute;
  top: 2px;
  right: 4px;
  background: none;
  border: none;
  color: var(--text-2);
  opacity: 0.75;
  font-size: 1rem;
  line-height: 1;
  padding: 8px;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.auth-card input[type="text"] {
  margin-top: 10px;
}

.auth-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-2);
  padding: 8px;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
}

/* ---------- Paywall (écran 3.5) ---------- */

.paywall-card {
  max-height: 90vh;
  overflow-y: auto;
  padding-right: 36px; /* dégage la croix de fermeture, toujours en haut à droite */
}

.paywall-title {
  font-size: 20px;
  font-weight: 500;
  line-height: 1.25;
  margin-top: 4px;
}

.paywall-benefits {
  width: 100%;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.paywall-benefit {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

.paywall-benefit svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--action);
}

.paywall-teaser-card {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2px 12px;
  margin-top: 14px;
}

.paywall-teaser-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  font-size: 12px;
  color: var(--text-2);
}

.paywall-teaser-row.bordered {
  border-bottom: 1px solid var(--border);
}

.paywall-teaser-row .paywall-teaser-task {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-2);
}

.paywall-teaser-row svg {
  flex-shrink: 0;
  color: var(--premium);
}

.paywall-teaser-more {
  color: var(--text);
}

.paywall-plans {
  width: 100%;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.paywall-plan {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
}

.paywall-plan.selected {
  border-color: var(--premium);
}

.paywall-plan-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.paywall-plan-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-2);
  margin-top: 2px;
}

.paywall-plan-badge {
  background: var(--premium);
  color: var(--on-color);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 500;
}

.paywall-disclaimer {
  font-size: 11px;
  color: var(--text-2);
  text-align: center;
  line-height: 1.3;
  margin-top: 10px;
}

.paywall-notnow {
  margin-top: 8px;
  align-self: center;
}

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 4px;
}

.link-button.premium {
  color: var(--premium);
}

.link-button.active {
  color: var(--text);
  text-decoration: none;
  cursor: default;
}

.quiet-links {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--text-2);
}

.subscription-message {
  color: var(--text);
  font-weight: 500;
  font-size: 0.95rem;
  text-align: center;
  margin-top: 20px;
}

.settings-section-title {
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
  text-align: center;
  margin-bottom: 10px;
}

.settings-row-label {
  font-size: 1rem;
  color: var(--text);
  text-align: center;
  margin-bottom: 8px;
}

.settings-static-value {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-2);
  font-size: 0.95rem;
}

.settings-delete-link {
  margin-top: 12px;
  color: var(--text-2);
}

.settings-language-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.help-list {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
}

.help-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.help-item:last-child {
  border-bottom: none;
}

.help-question {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.help-answer {
  color: var(--text-2);
  font-size: 0.95rem;
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .install-banner,
  .completion-block {
    animation: none;
  }
  .completion-icon.shown {
    animation: none;
  }
  .primary-button,
  .field-textarea,
  .progress-segment {
    transition: none;
  }
  .progress-bar-fill {
    animation: none;
  }
}
