/* ✦ Potion magique — neumorphism (ce qui est posé) + liquid glass (ce qui flotte sur la magie) */

:root {
  --bg: #efe5f2;
  --ink: #5362b5; /* bleu de la marque, assombri pour le contraste des petits textes (4,5:1 sur le lilas) */
  --ink-3: #6b6570; /* gris doux des petites mentions (4,6:1) */
  --danger: #a7486f;
  --ink-2: #525252;
  --pink: #f4c6dc;
  --rose: #ffe7eb;
  --sh-dark: rgba(152, 126, 186, 0.42);
  --sh-light: rgba(255, 255, 255, 0.95);
  --raised: 7px 7px 16px var(--sh-dark), -7px -7px 16px var(--sh-light);
  --raised-sm: 4px 4px 10px var(--sh-dark), -4px -4px 10px var(--sh-light);
  --pressed: inset 4px 4px 10px var(--sh-dark), inset -4px -4px 10px var(--sh-light);
  --flask-w: 240px;
  --flask-h: 400px;
  --flask-r: 58px;
  --lid-h: 26px;
  --display: 'Fraunces', Georgia, serif;

  /* jetons de couleur (thème clair) ; le thème sombre les redéfinit plus bas */
  --bg-light: #f7eef6;
  --bg-deep: #ebe0f3;
  --btn-top: #6571c0;
  --btn: #5362b5;
  --btn-bottom: #4a58a8;
  --on-primary: #fff;
  --on-danger: #fff;
  --btn-glow: rgba(83, 98, 181, 0.45);
  --lid-top: #fff;
  --lid-bottom: #f4eaf6;
  --sh-flask: rgba(110, 86, 168, 0.34);
  --verre-reflet: rgba(255, 255, 255, 0.55);
  --verre-haut: rgba(255, 255, 255, 0.5);
  --verre-bas: rgba(230, 218, 242, 0.35);
  --verre-liseré: rgba(255, 255, 255, 0.9);
  --verre-lueur: rgba(255, 255, 255, 0.4);
  --verre: rgba(255, 255, 255, 0.16);
  --givre: rgba(255, 255, 255, 0.5);
  --verre-bouton: rgba(255, 255, 255, 0.45);
  --verre-bouton-actif: rgba(255, 255, 255, 0.65);
  --verre-principal: rgba(83, 98, 181, 0.9);
  --verre-principal-actif: rgba(74, 88, 168, 0.95);
  --champ: rgba(255, 255, 255, 0.6);
  --placeholder: rgba(83, 98, 181, 0.6);
  --voile: rgba(70, 50, 120, 0.12);
  --trait: rgba(83, 98, 181, 0.18);
  --bouton-a: #fff;
  --bouton-b: #f4eaf8;
  --bouton-c: #e3d6f0;
  --interrupteur-contour: rgba(83, 98, 181, 0.75);
  --interrupteur-bouton: #fff;
}

/* ── Thème sombre « nuit bleue » (mode Dark des variables Figma) : textes et icônes blancs,
   bouton principal en violet pâle (le lilas du thème clair) ── */
html[data-theme='dark'] {
  color-scheme: dark;
  --bg: #171a2e;
  --bg-light: #1f2340;
  --bg-deep: #111426;
  --ink: #fff;
  --ink-2: #fff;
  --ink-3: #a59fb2;
  --danger: #f08bb0;
  --sh-dark: rgba(3, 4, 10, 0.8);
  --sh-light: rgba(93, 104, 166, 0.5);
  --btn-top: #f7eef6;
  --btn: #efe5f2;
  --btn-bottom: #e2d5ee;
  --on-primary: #161a2c;
  --on-danger: #161a2c;
  --btn-glow: rgba(239, 229, 242, 0.18);
  --lid-top: #262b4a;
  --lid-bottom: #1b1f36;
  --sh-flask: rgba(3, 4, 10, 0.75);
  --verre-reflet: rgba(255, 255, 255, 0.16);
  --verre-haut: rgba(255, 255, 255, 0.07);
  --verre-bas: rgba(44, 50, 89, 0.35);
  --verre-liseré: rgba(255, 255, 255, 0.28);
  --verre-lueur: rgba(255, 255, 255, 0.05);
  --verre: rgba(255, 255, 255, 0.08);
  --givre: rgba(44, 50, 89, 0.62);
  --verre-bouton: rgba(255, 255, 255, 0.12);
  --verre-bouton-actif: rgba(255, 255, 255, 0.2);
  --verre-principal: rgba(239, 229, 242, 0.92);
  --verre-principal-actif: rgba(226, 213, 238, 0.95);
  --champ: rgba(44, 50, 89, 0.62);
  --placeholder: rgba(255, 255, 255, 0.7);
  --voile: rgba(0, 0, 0, 0.4);
  --trait: rgba(255, 255, 255, 0.2);
  --bouton-a: #4a5285;
  --bouton-b: #343b68;
  --bouton-c: #262b4a;
  --interrupteur-contour: rgba(255, 255, 255, 0.55);
  --interrupteur-bouton: #2c3259;
}

* { box-sizing: border-box; }

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

body {
  background:
    radial-gradient(120% 60% at 50% 0%, var(--bg-light) 0%, transparent 60%),
    radial-gradient(90% 50% at 50% 100%, var(--bg-deep) 0%, transparent 70%),
    var(--bg);
  color: var(--ink-2);
  font-family: 'Outfit', system-ui, sans-serif;
  display: flex;
  justify-content: center;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

.app {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100dvh;
  max-height: 940px;
  overflow: hidden;
  overflow: clip; /* empêche tout défilement de l'app elle-même (ex. focus d'un bouton hors champ) */
}

/* ── Écrans ── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px);
  transition: opacity 0.45s ease, transform 0.45s ease, visibility 0s linear 0.45s;
}
.screen.active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.45s ease, transform 0.45s ease, visibility 0s;
}

canvas#potion {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.app > canvas#potion { display: none; }
.body > canvas#potion { border-radius: var(--flask-r); }

/* ── Logo (en attendant le logo définitif) ── */
.logo {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--display);
  font-variation-settings: 'SOFT' 100, 'WONK' 1;
  color: var(--ink);
  line-height: 0.82;
}
.logo-potion { font-size: 64px; font-weight: 600; letter-spacing: -0.01em; }
.logo-magique { font-size: 40px; font-weight: 600; font-style: italic; margin-left: 32px; }
.logo-star { position: absolute; top: -8px; right: 14px; font-size: 18px; color: var(--pink); }
.logo.big .logo-potion { font-size: 76px; }
.logo.big .logo-magique { font-size: 48px; }

[data-screen='splash'] {
  align-items: center;
  justify-content: center;
}
[data-screen='splash'].active .logo {
  animation: appear 1.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes appear {
  from { opacity: 0; transform: scale(0.92); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: none; }
}

/* ── Bienvenue ── */
[data-screen='welcome'] { justify-content: space-between; align-items: center; }
.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 0 14px;
}
.kicker {
  margin: 0;
  font-family: var(--display);
  font-variation-settings: 'SOFT' 100, 'WONK' 1;
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
}
.lead {
  margin: 18px 0 0;
  font-size: 16px;
  line-height: 1.55;
  font-weight: 300;
  color: var(--ink-2);
  max-width: 300px;
}

/* ── Titres et barre ── */
.screen-title {
  margin: 0;
  font-family: var(--display);
  font-variation-settings: 'SOFT' 100, 'WONK' 1;
  font-weight: 600;
  font-size: 24px;
  line-height: 1.15;
  color: var(--ink);
}
.screen-title.center { text-align: center; margin-top: 28px; font-size: 30px; }

.bar {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.neu-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: var(--raised-sm);
  color: var(--ink);
  display: grid;
  place-items: center;
  transition: box-shadow 0.18s ease;
}
.neu-btn:active { box-shadow: var(--pressed); }

.neu-pill {
  align-self: center;
  padding: 15px 26px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: var(--raised);
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 500;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.neu-pill:active { box-shadow: var(--pressed); transform: scale(0.98); }
.neu-pill.primary {
  background: linear-gradient(160deg, var(--btn-top) 0%, var(--btn) 60%, var(--btn-bottom) 100%);
  color: var(--on-primary);
  box-shadow: 6px 8px 18px var(--btn-glow), -6px -6px 14px var(--sh-light), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.neu-pill.primary:active { transform: scale(0.97); }
.neu-pill.wide { width: 100%; margin-top: 12px; }

/* ── Scène du flacon ── */
.stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
}
.stage > * { grid-area: 1 / 1; }


.glow {
  width: calc(var(--flask-w) * 1.25);
  height: calc(var(--flask-h) * 0.95);
  border-radius: 50%;
  filter: blur(38px);
  opacity: 0.5;
  pointer-events: none;
  animation: breathe 7s ease-in-out infinite;
  transition: background 1s ease;
}
@keyframes breathe {
  0%, 100% { transform: scale(0.94); opacity: 0.42; }
  50% { transform: scale(1.04); opacity: 0.58; }
}

.flask {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lid {
  position: relative;
  z-index: 2;
  width: 58%;
  height: var(--lid-h);
  margin-bottom: -6px;
  border-radius: 12px 12px 7px 7px;
  background: linear-gradient(180deg, var(--lid-top) 0%, var(--lid-bottom) 100%);
  box-shadow: var(--raised-sm), inset 0 -4px 0 rgba(83, 98, 181, 0.08);
}

.body {
  position: relative;
  width: var(--flask-w);
  height: var(--flask-h);
  border-radius: var(--flask-r);
  box-shadow:
    16px 20px 34px var(--sh-flask),
    -12px -12px 26px var(--sh-light);
}

/* flacon vide : juste du verre */
.empty-glass {
  background:
    linear-gradient(100deg, transparent 12%, var(--verre-reflet) 15%, transparent 19%),
    linear-gradient(180deg, var(--verre-haut), var(--verre-bas));
  box-shadow:
    inset 2px 2px 0 var(--verre-liseré),
    inset -2px -2px 6px rgba(152, 126, 186, 0.25),
    inset 0 0 30px var(--verre-lueur),
    14px 18px 30px var(--sh-flask),
    -10px -10px 22px var(--sh-light);
}
[data-screen='empty'] .neu-pill { margin-bottom: 12px; }

/* ── Panneau des ingrédients ── */
.panel {
  margin-top: 6px;
  padding: 12px;
  border-radius: 30px;
  background: var(--bg);
  box-shadow: var(--raised);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  box-shadow: var(--pressed);
}
.tabs button {
  padding: 9px 4px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-2);
  transition: all 0.2s ease;
}
.tabs button.active {
  background: var(--bg);
  box-shadow: var(--raised-sm);
  color: var(--ink);
  opacity: 1;
}

.chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 4px 9px;
  border-radius: 20px;
  background: var(--bg);
  box-shadow: var(--raised-sm);
  transition: box-shadow 0.2s ease;
}
.chip.selected { box-shadow: var(--pressed); }

/* plus de 3 choix : rangée qui défile horizontalement */
.chips.scroll {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  /* l'aimantation respecte la marge de gauche : la première vignette ne se colle plus au bord */
  scroll-padding-inline: 12px;
  overscroll-behavior-x: contain;
  margin: 12px -12px 0;
  padding: 4px 12px 10px;
  scrollbar-width: none;
}
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.scroll .chip {
  flex: 0 0 calc((100% - 20px) / 3.3);
  scroll-snap-align: start;
}
.chip .swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  box-shadow: 2px 2px 5px var(--sh-dark), -2px -2px 5px var(--sh-light), inset 0 0 0 1.5px rgba(255, 255, 255, 0.6);
}
.chip span {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  text-align: center;
  line-height: 1.15;
}
.chip.selected span { color: var(--ink); }

/* ── Donne-lui un nom ── */
.label-input {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 78%;
  padding: 14px 12px;
  border: none;
  border-radius: 16px;
  background: var(--champ);
  color: var(--ink);
  font-family: var(--display);
  font-variation-settings: 'SOFT' 100, 'WONK' 1;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  outline: none;
  user-select: text;
}
.label-input::placeholder { color: var(--placeholder); font-weight: 400; font-size: 14px; }
.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 6px 30px 8px;
}
.actions .neu-pill { width: 100%; }

/* ── Potion en plein écran ── */
[data-screen='potion'] { padding: 0; }
.full { position: absolute; inset: 0; }
.round {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  z-index: 3;
}
.back-float { left: 16px; }
.settings-float { right: 16px; }
.potion-name {
  position: absolute;
  top: max(24px, calc(env(safe-area-inset-top) + 8px));
  left: 72px;
  right: 72px;
  margin: 0;
  text-align: center;
  font-family: var(--display);
  font-variation-settings: 'SOFT' 100, 'WONK' 1;
  font-size: 22px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 12px rgba(40, 20, 80, 0.45);
  pointer-events: none;
  z-index: 3;
}
.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(26px, env(safe-area-inset-bottom));
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: #fff;
  text-shadow: 0 1px 8px rgba(40, 20, 80, 0.5);
  pointer-events: none;
  transition: opacity 0.8s ease;
  z-index: 3;
}
.hint.gone { opacity: 0; }

/* ── Tes potions ── */
.collection-head {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  align-items: start;
  gap: 8px;
  text-align: center;
  padding: 18px 0 6px;
}
.collection-head .screen-title { font-size: 32px; }
.subtitle {
  margin: 4px 0 0;
  font-size: 12.5px;
  font-weight: 300;
  letter-spacing: 0.04em;
}
.grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: start;
  gap: 22px 14px;
  padding: 26px 4px 30px;
  scrollbar-width: none;
}
.grid::-webkit-scrollbar { display: none; }
.vial {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.vial .mini-lid {
  width: 56%;
  height: 12px;
  margin-bottom: -4px;
  z-index: 1;
  border-radius: 6px 6px 4px 4px;
  background: linear-gradient(180deg, var(--lid-top), var(--lid-bottom));
  box-shadow: 2px 2px 5px var(--sh-dark), -2px -2px 5px var(--sh-light);
}
.vial .mini-body {
  width: 100%;
  aspect-ratio: 0.6;
  border-radius: 24%/14%;
  background: center / cover no-repeat;
  box-shadow: 6px 8px 16px var(--sh-flask), -6px -6px 14px var(--sh-light);
  transition: transform 0.2s ease;
}
.vial:active .mini-body { transform: scale(0.96); }
.vial span {
  max-width: 100%;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  text-align: center;
  line-height: 1.2;
}
.vial.add .mini-body {
  display: grid;
  place-items: center;
  background: var(--bg);
  box-shadow: var(--pressed);
  color: var(--ink);
  font-size: 34px;
  font-weight: 300;
}

/* ── Liquid glass ── */
.glass {
  background: var(--verre);
  -webkit-backdrop-filter: blur(4px) saturate(1.8) brightness(1.08);
  backdrop-filter: blur(4px) saturate(1.8) brightness(1.08);
  box-shadow:
    inset 1.5px 1.5px 0 rgba(255, 255, 255, 0.8),
    inset -1px -1px 0 rgba(255, 255, 255, 0.35),
    inset 0 0 20px rgba(255, 255, 255, 0.22),
    0 10px 30px rgba(60, 40, 120, 0.22);
}
.lg .glass {
  backdrop-filter: url(#liquid-glass) saturate(1.8) brightness(1.08);
}
.glass.frost {
  background: var(--givre);
  -webkit-backdrop-filter: blur(14px) saturate(1.7) brightness(1.06);
  backdrop-filter: blur(14px) saturate(1.7) brightness(1.06);
}
.lg .glass.frost {
  backdrop-filter: url(#liquid-glass) blur(14px) saturate(1.7) brightness(1.06);
}
.label-input.glass { background: var(--champ); }

/* ── Feuille de réglages (liquid glass) ── */
.sheet {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 10;
  padding: 18px 20px 20px;
  border-radius: 30px;
  transform: translateY(calc(100% + 40px));
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.25, 1);
}
.sheet.open { transform: none; }

.scrim {
  position: absolute;
  inset: 0;
  z-index: 9;
  background: var(--voile);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.scrim.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.sheet h2 {
  margin: 0;
  font-family: var(--display);
  font-variation-settings: 'SOFT' 100, 'WONK' 1;
  font-size: 22px;
  color: var(--ink);
}
.close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink);
}

.slider {
  display: grid;
  grid-template-columns: 92px 1fr 40px;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
}
.slider output {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  opacity: 0.9;
}
/* zone tactile haute (44px) mais rail fin */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  outline: none;
  touch-action: pan-x;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--trait);
  box-shadow: inset 1px 1px 3px rgba(60, 30, 110, 0.25);
}
input[type='range']::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--trait);
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  margin-top: -11px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--bouton-a) 0%, var(--bouton-b) 60%, var(--bouton-c) 100%);
  box-shadow: 0 3px 8px rgba(60, 30, 110, 0.35), inset 0 -2px 3px rgba(83, 98, 181, 0.2);
}
input[type='range']::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--bouton-a) 0%, var(--bouton-b) 60%, var(--bouton-c) 100%);
  box-shadow: 0 3px 8px rgba(60, 30, 110, 0.35);
}

.delete {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border-radius: 999px;
  background: var(--verre-bouton);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.8);
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 600;
}
.delete.confirm { background: var(--danger); color: var(--on-danger); }

.error {
  position: absolute;
  inset: auto 20px 50% 20px;
  padding: 16px;
  border-radius: 20px;
  background: var(--bg);
  box-shadow: var(--raised);
  color: var(--ink);
  text-align: center;
  font-size: 14px;
  z-index: 20;
}

/* ── V1.2 : renommer, menu de l'appui long, glisser-déposer ── */
button.potion-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: auto;
  line-height: 1.15;
}
button.potion-name svg { flex: none; opacity: 0.85; filter: drop-shadow(0 1px 6px rgba(40, 20, 80, 0.45)); }

.version {
  margin: 0;
  padding: 4px 0 2px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.grid { touch-action: pan-y; -webkit-touch-callout: none; }
.vial { touch-action: pan-y; -webkit-user-select: none; transition: opacity 0.2s ease; }
.vial.lifted .mini-body { transform: scale(1.06); box-shadow: 10px 14px 26px var(--sh-flask), -6px -6px 14px var(--sh-light); }
.vial.placeholder { opacity: 0.25; }
.vial.ghost {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  transform-origin: center;
}
.vial.ghost .mini-body { transform: scale(1.08) rotate(-3deg); }

.menu {
  position: absolute;
  z-index: 12;
  min-width: 200px;
  padding: 8px;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.25, 1.2);
}
.menu[hidden] { display: none; }
@keyframes pop {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: none; }
}
.menu-title {
  margin: 4px 12px 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--trait);
  font-family: var(--display);
  font-variation-settings: 'SOFT' 100, 'WONK' 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}
.menu button {
  padding: 12px 14px;
  border-radius: 14px;
  text-align: left;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}
.menu button:active { background: var(--verre-bouton-actif); }
.menu button.danger { color: var(--danger); }
.menu button.danger.confirm { background: var(--danger); color: var(--on-danger); }

.dialog {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 50%;
  z-index: 12;
  padding: 22px 20px 20px;
  border-radius: 28px;
  transform: translateY(-50%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.dialog.open { opacity: 1; pointer-events: auto; transform: translateY(-50%); }
.dialog h2 {
  margin: 0 0 14px;
  font-family: var(--display);
  font-variation-settings: 'SOFT' 100, 'WONK' 1;
  font-size: 22px;
  color: var(--ink);
}
.field {
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 16px;
  background: var(--champ);
  box-shadow: inset 2px 2px 6px var(--sh-dark);
  color: var(--ink);
  font-family: var(--display);
  font-variation-settings: 'SOFT' 100, 'WONK' 1;
  font-size: 18px;
  font-weight: 600;
  outline: none;
  user-select: text;
}
.link {
  margin: 10px 2px 16px;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.dialog .row { display: flex; gap: 10px; }
.dialog .row .neu-pill { flex: 1; padding: 13px 10px; }

/* noms longs (jusqu'à 40 caractères) : l'étiquette grandit jusqu'à 3 lignes, les titres sont limités à 2 lignes */
textarea.label-input {
  resize: none;
  overflow: hidden;
  line-height: 1.2;
  width: 86%;
  font-size: 16px;
  padding: 12px 10px;
}
#potion-name, .vial span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
button.potion-name { font-size: 20px; }

/* ── V1.3 : flacon qui se remplit, boutons en verre ── */

.flask { position: relative; }
.flask .body { z-index: 1; }

/* création : le flacon est vide tant qu'aucune couleur n'est choisie, puis le liquide monte */
.stage .body {
  background:
    linear-gradient(100deg, transparent 12%, var(--verre-reflet) 15%, transparent 19%),
    linear-gradient(180deg, var(--verre-haut), var(--verre-bas));
}
.stage .body > canvas#potion {
  clip-path: inset(0 round var(--flask-r));
  transition: clip-path 1.6s cubic-bezier(0.3, 0.7, 0.2, 1);
}
.stage.vide .body > canvas#potion { clip-path: inset(100% 0 0 0 round var(--flask-r)); transition: none; }
.stage.vide .glow { opacity: 0; animation: none; }
.glow { transition: background 1s ease, opacity 1s ease; }

.tabs button:disabled { opacity: 0.3; cursor: default; }
.neu-pill:disabled { opacity: 0.55; cursor: default; }
.neu-pill.primary:disabled { box-shadow: var(--raised-sm); }

/* Deux familles de boutons :
   - neumorphism (.neu-pill, .neu-btn) quand le bouton est posé sur le fond lilas des écrans ;
   - verre (.glass-pill, .round.glass) quand il flotte sur la potion ou dans un élément en verre (feuille, menu, fenêtre). */
.glass-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 16px;
  border-radius: 999px;
  background: var(--verre-bouton);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.85), inset -1px -1px 0 rgba(255, 255, 255, 0.3), 0 4px 12px rgba(60, 40, 120, 0.1);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  transition: transform 0.15s ease, background 0.15s ease;
}
.glass-pill:active { transform: scale(0.97); background: var(--verre-bouton-actif); }
.glass-pill.primary {
  background: var(--verre-principal);
  color: var(--on-primary);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.45), 0 6px 16px var(--btn-glow);
}
.glass-pill.primary:active { background: var(--verre-principal-actif); }
.glass-pill.wide { width: 100%; margin-top: 10px; }
.dialog .row .glass-pill { flex: 1; }

/* ── V1.4 : Mes couleurs ── */
.chip.perso span { color: var(--ink); }
#perso .sheet-head { margin-bottom: 12px; }
.moods {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--verre-bouton);
  box-shadow: inset 1px 1px 3px rgba(60, 30, 110, 0.15);
}
.moods button {
  padding: 10px 4px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  transition: all 0.2s ease;
}
.moods button.active {
  color: var(--on-primary);
  background: var(--btn);
  box-shadow: 0 2px 8px var(--btn-glow);
}
.dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 20px 0 14px;
}
.dot {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.7), 0 3px 8px rgba(60, 30, 110, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.dot.active {
  transform: scale(1.12);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.95), 0 0 0 5px var(--ink), 0 4px 10px rgba(60, 30, 110, 0.3);
}
/* la bande des teintes, à la clarté de l'ambiance choisie */
input.hue::-webkit-slider-runnable-track {
  height: 14px;
  background: linear-gradient(90deg,
    hsl(0 var(--s) var(--l)), hsl(60 var(--s) var(--l)), hsl(120 var(--s) var(--l)), hsl(180 var(--s) var(--l)),
    hsl(240 var(--s) var(--l)), hsl(300 var(--s) var(--l)), hsl(360 var(--s) var(--l)));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}
input.hue::-moz-range-track {
  height: 14px;
  background: linear-gradient(90deg,
    hsl(0 var(--s) var(--l)), hsl(60 var(--s) var(--l)), hsl(120 var(--s) var(--l)), hsl(180 var(--s) var(--l)),
    hsl(240 var(--s) var(--l)), hsl(300 var(--s) var(--l)), hsl(360 var(--s) var(--l)));
}
input.hue::-webkit-slider-thumb {
  margin-top: -8px;
  width: 30px;
  height: 30px;
  background: var(--c);
  box-shadow: 0 0 0 3px #fff, 0 3px 10px rgba(60, 30, 110, 0.4);
}
input.hue::-moz-range-thumb { background: var(--c); box-shadow: 0 0 0 3px #fff; }

.dialog-text {
  margin: -4px 0 18px;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--ink-2);
}

.nowrap { white-space: nowrap; }

/* ── V1.13 : réglages de l'app, accessibilité ── */

/* Réglages de la collection : langue, accessibilité */
.pref { margin-top: 16px; }
.pref-label {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.pref-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.pref-switch .pref-label { margin-bottom: 4px; }
.pref-hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-2);
}
#prefs .version { margin-top: 18px; }

/* interrupteur en verre : gris quand il est éteint, bleu quand il est allumé */
.switch {
  position: relative;
  flex: none;
  width: 56px;
  height: 34px;
  border-radius: 999px;
  background: var(--verre-bouton);
  /* éteint : un contour violet (3:1 sur le verre) pour qu'on le voie bien */
  box-shadow: inset 0 0 0 2px var(--interrupteur-contour), inset 1px 1px 4px rgba(60, 30, 110, 0.22);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.switch span {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--interrupteur-bouton);
  box-shadow: 0 2px 6px rgba(60, 30, 110, 0.3);
  transition: transform 0.2s ease;
  /* le petit bonhomme de l'accessibilité, dans le bouton rond */
  display: grid;
  place-items: center;
  color: var(--ink);
}
.switch[aria-checked='true'] { background: var(--btn); box-shadow: inset 1px 1px 4px rgba(30, 20, 80, 0.3); }
.switch[aria-checked='true'] span { transform: translateX(22px); }
/* une zone à toucher de 48 px autour de l'interrupteur */
.switch::after { content: ''; position: absolute; inset: -7px -4px; }

/* sur la potion : étiquette et boutons givrés, icônes et texte en violet, lisibles sur toutes les couleurs */
.round.frost, button.potion-name.frost { color: var(--ink); }
button.potion-name.frost {
  left: 76px;
  right: 76px;
  width: max-content;
  max-width: calc(100% - 152px);
  min-height: 48px;
  margin: 0 auto;
  top: max(15px, calc(env(safe-area-inset-top) - 1px));
  padding: 8px 18px;
  border-radius: 24px;
  text-shadow: none;
}
button.potion-name.frost svg { opacity: 1; filter: none; }

/* texte réservé au lecteur d'écran */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* noms des flacons : on revient à la ligne entre les mots, avec une césure si un mot est trop long */
.vial span { overflow-wrap: normal; word-break: normal; hyphens: auto; }

/* ── États focus (navigation au clavier ou au contacteur) ──
   un anneau bleu détaché de l'élément, qui suit ses arrondis ;
   sur la potion, un anneau blanc doublé de bleu, visible sur toutes les couleurs */
:focus { outline: none; }
:focus-visible {
  outline: 2.5px solid var(--ink);
  outline-offset: 3px;
}
.round:focus-visible, button.potion-name:focus-visible {
  outline: 2.5px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 7px var(--ink);
}
.chip:focus-visible, .vial:focus-visible { outline-offset: 4px; border-radius: 22px; }
input[type='range']:focus-visible { outline-offset: 6px; border-radius: 999px; }
.dot:focus-visible { outline-offset: 5px; }
/* les champs de texte : l'anneau n'apparaît qu'en navigation au clavier (au doigt, le curseur suffit) */
html.clavier .field:focus, html.clavier .label-input:focus { outline: 2.5px solid var(--ink); outline-offset: 3px; }
/* la feuille ou la fenêtre qui reçoit le focus à l'ouverture n'a pas d'anneau */
.sheet:focus-visible, .dialog:focus-visible, .menu:focus-visible { outline: none; }

/* ── Mode accessibilité : animations calmées ── */
html.calme *, html.calme *::before, html.calme *::after {
  transition-duration: 0.01s !important;
  animation-duration: 0.01s !important;
  animation-iteration-count: 1 !important;
}
html.calme .screen { transform: none; }

/* l'indice « Touche, penche ou secoue » : étiquette givrée, en violet */
.hint.frost {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 48px);
  padding: 10px 18px;
  border-radius: 999px;
  color: var(--ink);
  font-weight: 500;
  text-shadow: none;
}

/* mode accessibilité : le pincement à deux doigts zoome partout ;
   un seul doigt garde son rôle (défiler la collection, remuer la potion, régler un curseur) */
html.calme .grid, html.calme .vial { touch-action: pan-y pinch-zoom; }
html.calme input[type='range'] { touch-action: pan-x pinch-zoom; }
html.calme canvas#potion { touch-action: pinch-zoom; }

/* choix de la langue : il épouse son contenu (hug) ; comme toutes les pastilles de choix, la sélection est en violet plein */
.moods.langues-choix {
  display: inline-grid;
  grid-template-columns: repeat(2, auto);
}
.langues-choix button { padding: 10px 20px; }

/* Réglages : sauvegarde des potions */
.pref-actions { display: flex; gap: 10px; margin-top: 10px; }
.pref-actions .glass-pill { flex: 1; padding: 11px 12px; }
.pref-date { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); }

/* Toast : petit message givré en bas de l'écran */
.toast {
  position: absolute;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 10px 10px 18px;
  border-radius: 24px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast:not(:has(.toast-action:not([hidden]))) { padding-right: 18px; }
.toast-action {
  flex: none;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--btn);
  color: var(--on-primary);
  font-size: 13.5px;
  font-weight: 600;
}

/* bouton rond « fond d'écran » à droite des réglages ; les réglages se décalent d'un cran */
.capture-float { right: 16px; }
.settings-float { right: 70px; }
button.potion-name.frost { left: 72px; right: 124px; max-width: calc(100% - 196px); }

/* l'éclair blanc de la photo */
.flash {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.flash.on { animation: flash 0.5s ease-out; }
@keyframes flash {
  from { opacity: 0.85; }
  to { opacity: 0; }
}

/* interrupteur du mode sombre : un soleil en clair, une lune en sombre */
.switch-theme .lune { display: none; }
.switch-theme[aria-checked='true'] .soleil { display: none; }
.switch-theme[aria-checked='true'] .lune { display: block; }
