/* Identité visuelle FORM. — couleurs définies uniquement ici */
:root {
  --bg: #000000;               /* fond général, header, navigation, safe areas */
  --card: #121212;             /* cartes et surfaces */
  --surface-2: #1C1C1C;        /* champs et boutons secondaires */
  --border: #292929;           /* bordures et séparateurs */
  --text: #FFFFFF;             /* titres et chiffres */
  --text-2: #A0A0A0;           /* textes secondaires */
  --lime: #C8F568;             /* accent */
  --overlay: rgba(0, 0, 0, 0.7);

  /* Alias et nuances dérivées */
  --bg-deep: var(--surface-2); /* champs de saisie */
  --hairline: var(--border);
  --lime-hi: #D3F884;          /* ton sur ton du bouton lime */
  --shadow: rgba(0, 0, 0, 0.6);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --topbar-h: 56px;
  --tabbar-h: 64px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --fast: 140ms;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }

/* Barre du haut */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border-bottom: 1px solid var(--hairline);
  z-index: 10;
}

.logo { font-size: 22px; font-weight: 900; letter-spacing: -0.01em; }
.logo-dot { color: var(--lime); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  margin-right: -10px;
  color: var(--text-2);
}
.icon-btn.active { color: var(--lime); }

/* Contenu */
#app {
  padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 24px) 20px
           calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  min-height: 100dvh;
}

.page-title { font-size: 32px; font-weight: 900; letter-spacing: -0.02em; line-height: 1.1; }
#app > * { animation: page-in 220ms var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }

/* Chiffres nets et alignés ; unités plus petites que les valeurs */
strong, .day-n, .ring-in strong { font-variant-numeric: tabular-nums; }
.unit { font-size: 0.62em; font-weight: 600; color: var(--text-2); margin-left: 3px; letter-spacing: 0; }

/* Barre de navigation inférieure */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg);
  border-top: 1px solid var(--hairline);
  z-index: 10;
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  transition: color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.tabbar a:active { transform: scale(0.92); }
.tabbar a.active { color: var(--lime); font-weight: 800; }

/* Composants communs */
.muted { color: var(--text-2); }

/* Surfaces : contraste graphite plutôt qu'ombres */
.card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  padding: 18px;
}

/* Boutons : pilule, typographie affirmée, compression à l'appui */
.btn-primary, .btn-secondary, .btn-ghost {
  min-height: 52px;
  padding: 0 24px;
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1;
  cursor: pointer;
  transition: transform var(--fast) var(--ease), background-color var(--fast) var(--ease),
    opacity var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.btn-primary, .btn-secondary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary {
  background: linear-gradient(180deg, var(--lime-hi), var(--lime));
  color: var(--bg); border: 0;
  box-shadow: 0 10px 20px -14px var(--shadow);
}
/* Action de confirmation dans un panneau : blanc, un cran sous le lime des écrans */
.sheet .btn-primary { background: var(--text); box-shadow: none; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--hairline); }
.btn-ghost { min-height: 40px; background: none; color: var(--lime); border: 0; padding: 0; align-self: flex-start; font-weight: 700; }
.btn-primary:active, .btn-secondary:active { transform: scale(0.97); }
.btn-primary:active { box-shadow: none; }
.btn-ghost:active { opacity: 0.6; }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.35; transform: none; box-shadow: none; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
.block { width: 100%; }
.danger { color: var(--text-2); }
.back { color: var(--text-2); font-size: 14px; font-weight: 600; }
.menu { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.menu .btn-ghost { align-self: center; }

.nav-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 999px;
  background: none; border: 0; color: var(--text); font: inherit;
  transition: background-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.nav-btn:active { background: var(--surface-2); transform: scale(0.92); }
.nav-btn:disabled { opacity: 0.3; }
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 0 14px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--hairline);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 700; white-space: nowrap;
  transition: transform var(--fast) var(--ease), background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.chip:active { transform: scale(0.95); }
.chip:disabled { opacity: 0.35; }
.chip-lime { color: var(--bg); background: var(--lime); border-color: var(--lime); font-weight: 800; }

/* Champs : léger effet creusé */
input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-deep);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: inset 0 1px 3px var(--shadow);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* évite le zoom automatique d'iOS */
  font-weight: 600;
  color-scheme: dark;
  transition: border-color var(--fast) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-2); font-weight: 500; }
input[type="radio"], input[type="checkbox"] { width: auto; accent-color: var(--lime); box-shadow: none; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--lime); }
textarea { resize: vertical; }

.mini { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.grid2, .grid3 { display: grid; gap: 8px; }
.grid2 { grid-template-columns: repeat(2, 1fr); }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 15px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 12px; }

/* Panneau modal */
body.no-scroll { overflow: hidden; }
.sheet-overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: flex-end;
  background: var(--overlay);
  animation: fade-in 180ms var(--ease);
}
.sheet {
  width: 100%;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--hairline);
  border-radius: 28px 28px 0 0;
  animation: sheet-up 240ms var(--ease);
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0.6; } }
.sheet-title { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; margin-bottom: 18px; }

/* Mise à jour disponible (PWA) */
.update-bar {
  position: fixed; left: 12px; right: 12px; z-index: 30;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  font-size: 14px; font-weight: 700;
  animation: sheet-up 240ms var(--ease);
}
.save-error { border-radius: 18px; border-color: var(--text); z-index: 31; }

/* Accessibilité : mouvements réduits */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
.sheet-actions { display: flex; gap: 8px; margin-top: 8px; }
.sheet-actions > * { flex: 1; }
