:root{
  --bordeaux:#7C183C;
  --bordeaux-dark:#5D1029;
  --cuivre:#B4794A;
  --ink:#1B1B1B;
  --muted:#6B6B6B;
  --line:#E4E4E4;
  --bg:#FFFFFF;
  --bg-soft:#F4F4F4;
  --card:#ECECEC;
  --bubble-user:#591A42;
  --bubble-bot:#EDEDED;
  --radius:16px;
  --shadow:0 2px 10px rgba(0,0,0,.08);
  --safe-bottom:env(safe-area-inset-bottom, 0px);
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;height:100%;}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  color:var(--ink);background:var(--bg);
  -webkit-font-smoothing:antialiased;
}
.app{display:flex;flex-direction:column;height:100dvh;max-width:520px;margin:0 auto;background:var(--bg);}

/* ---- Top bar ---- */
.topbar{
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  padding:12px 14px;border-bottom:1px solid var(--line);background:#fff;
  position:sticky;top:0;z-index:5;
}
.brand{display:flex;align-items:center;}
.brand-logo{height:30px;width:auto;display:block;}
.icon-btn{
  border:0;background:transparent;color:var(--ink);width:36px;height:36px;border-radius:50%;
  display:grid;place-items:center;cursor:pointer;
}
.icon-btn svg{width:22px;height:22px;}
.icon-btn:hover{background:var(--bg-soft);}
/* Masqué mais réserve sa place : le logo reste centré avant l'apparition du bouton. */
.icon-btn[hidden]{display:grid;visibility:hidden;pointer-events:none;}

/* ---- Thread ---- */
.thread{flex:1;overflow-y:auto;padding:18px 16px 8px;scroll-behavior:smooth;}

/* ---- Messages ---- */
.msg{max-width:82%;padding:11px 15px;border-radius:18px;margin:10px 0;line-height:1.45;font-size:15.5px;white-space:pre-wrap;word-wrap:break-word;}
.msg.user{margin-left:auto;background:var(--bubble-user);color:#fff;border-bottom-right-radius:5px;}
.msg.bot{margin-right:auto;background:var(--bubble-bot);color:var(--ink);border-bottom-left-radius:5px;}
.msg.bot.status{background:#FBEEF0;border:1px solid #F0C9D2;color:var(--bordeaux-dark);}
/* Markdown rendu dans les bulles de l'agent (paragraphes + listes compactes). */
.msg.bot p{margin:0 0 8px;}
.msg.bot p:last-child{margin-bottom:0;}
.msg.bot ul{margin:6px 0;padding-left:20px;}
.msg.bot ul:last-child{margin-bottom:0;}
.msg.bot li{margin:2px 0;}
.msg.bot strong{font-weight:700;}

/* ---- Typing indicator ---- */
.typing{display:inline-flex;gap:4px;align-items:center;}
.typing span{width:7px;height:7px;border-radius:50%;background:var(--muted);opacity:.5;animation:blink 1.2s infinite;}
.typing span:nth-child(2){animation-delay:.2s;}
.typing span:nth-child(3){animation-delay:.4s;}
@keyframes blink{0%,60%,100%{opacity:.25;}30%{opacity:.9;}}

/* ---- Reco cards ---- */
.reco {
  position: relative; display: flex; gap: 10px; align-items: stretch;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  margin: 8px 0; box-shadow: var(--shadow);
  
  /* NOUVEAU : On verrouille strictement toutes les cartes à 160px de haut */
  height: 200px; 
}
.reco-body{flex:1;padding:14px 14px 14px 16px;min-width:0;}
.chip{display:inline-block;background:var(--bordeaux);color:#fff;font-size:11px;font-weight:700;
  padding:3px 10px;border-radius:999px;text-transform:none;margin-bottom:8px;}
.reco-name{margin:0 0 4px;font-size:16px;font-weight:800;line-height:1.2;}
.reco-pairings-label{font-size:12.5px;color:var(--muted);}
.pairing-icons{display:flex;gap:8px;margin-top:6px;flex-wrap:wrap;align-items:center;}
.pairing-icons img{width:26px;height:26px;object-fit:contain;}
.pairing-icons .pill{font-size:11px;color:var(--muted);background:var(--bg-soft);padding:2px 8px;border-radius:999px;}
.reco-macaron {
  position: relative; 
  display: flex; 
  align-items: center; 
  justify-content: center;
  
  /* On supprime le pourcentage de largeur et on lui dit 
     de prendre 100% de la hauteur de la carte (donc 160px) */
  height: 100%;
  aspect-ratio: 1; /* Il restera un carré parfait de 160x160px */
  flex-shrink: 0; /* On l'empêche de s'écraser si le texte est long */
}
.reco-macaron img{width:100%;height:100%;object-fit:contain;}
/* Superposition absolue obligatoire : .reco-macaron est en display:flex, donc
   sans position:absolute le SVG devient un 2e enfant flex a cote de l'image
   (au lieu de la recouvrir) et les deux se retrouvent ecrases/mal alignes. */
.reco-macaron .radar{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;}

/* ---- Bandeau région ---- */
.reco-region {
  position: relative;
  /* On revient à la bonne épaisseur de 40px */
  flex: 0 0 40px; 
  background-color: var(--bordeaux);
  overflow: hidden;
}

.reco-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  
  /* C'est ici que ça se joue : 200px correspond à votre nouvelle hauteur de carte */
  width: 200px; 
  height: 40px;
  
  /* 'cover' est la propriété parfaite ici : 
     Elle force l'image à remplir l'espace de 200x40 en gardant son ratio. 
     Rien ne sera déformé, et le fond bois touchera parfaitement les bords ! */
  object-fit: cover; 
  
  transform: translate(-50%, -50%) rotate(-90deg);
}

/* On stylise le texte natif pour qu'il soit vertical */
.reco-region-text {
  position: relative;
  z-index: 2; /* Au-dessus de l'image de fond */
  color: #FFFFFF;
  font-size: 22px; /* À ajuster selon le rendu souhaité */
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
  
  /* L'astuce magique pour écrire à la verticale de bas en haut */
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
/* ---- Reco carte vin (vin précis : photo bouteille + note) ---- */
.reco--wine{cursor:pointer;}
.reco--wine .reco-body{padding:14px 6px 14px 4px;}
.wine-cart-btn{
  position:absolute;top:8px;right:48px;width:44px;height:44px;border:0;border-radius:50%;
  background:var(--bordeaux);color:#fff;display:grid;place-items:center;cursor:pointer;
  transition:transform .1s, opacity .15s;z-index:2;
}
.wine-cart-btn svg{width:22px;height:22px;}
.wine-cart-btn:active{transform:scale(.92);}
.wine-cart-btn:hover{opacity:.9;}
.reco-bottle {
  flex: 0 0 88px; /* Définit une largeur fixe de 88px pour la zone de l'image */
  display: flex; align-items: center; justify-content: center;
  margin: 12px 0 12px 12px; background: #fff; border-radius: 12px; overflow: hidden;
}
.reco-bottle img {
  width: 100%; 
  height: 100%; 
  max-height: 150px; /* Limite la hauteur pour que ça ne dépasse pas de la carte */
  object-fit: contain; 
  padding: 6px;
}
/* ---- Disposition en 2 colonnes (Infos à gauche, Accords à droite) ---- */
.wine-split {
  display: flex;
  gap: 12px; /* Espace entre les deux colonnes */
  align-items: flex-start; /* Aligne le tout vers le haut */
}

/* La colonne de gauche */
.wine-infos {
  flex: 1; /* Prend un maximum de place */
  min-width: 0; /* Empêche le texte long de casser la carte */
}

/* La colonne de droite (Accords) */
.wine-split .reco-pairings {
  flex: 0 0 45%; /* Garde environ 45% de la largeur pour les icônes */
  margin-top: 0;
}

/* On ajuste les marges internes de la colonne de gauche pour que ce soit compact */
.wine-winery {
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  margin: 0 0 2px;
}
.wine-appellation { margin: 0 0 6px; }
.wine-note { 
  display: none !important;
}
.wine-note-label{color:var(--muted);}
.wine-note strong{color:var(--bordeaux);font-weight:800;}
.wine-note-count{color:var(--muted);font-size:11px;}

/* Le titre (AOC) s'autorise 2 lignes maximum */
.reco-name, 
.wine-appellation {
  white-space: normal; /* Annule l'interdiction de passer à la ligne */
  display: -webkit-box;
  -webkit-line-clamp: 2; /* Préfixe pour la compatibilité actuelle (Safari, Chrome, Edge...) */
  line-clamp: 2; /* Propriété standard pour la compatibilité future */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.reco-sep{font-size:13px;color:var(--muted);margin:14px 2px 4px;text-align:center;}

/* ---- Composer ---- */
.composer{display:flex;gap:10px;align-items:center;padding:10px 14px;border-top:1px solid var(--line);background:#fff;}
.input{
  flex:1;border:1px solid var(--line);background:#fff;border-radius:999px;
  padding:13px 18px;font-size:16px;outline:none;box-shadow:var(--shadow);
}
.input:focus{border-color:var(--bordeaux);}
.send{
  width:48px;height:48px;flex:none;border:0;border-radius:50%;background:var(--bordeaux);color:#fff;
  display:grid;place-items:center;cursor:pointer;transition:opacity .15s, transform .08s;
}
.send:disabled{opacity:.4;cursor:default;}
.send:not(:disabled):active{transform:scale(.94);}
.send svg{width:22px;height:22px;}

/* ---- Legal footer ---- */
.legal{font-size:10.5px;color:var(--muted);text-align:center;padding:8px 16px calc(10px + var(--safe-bottom));line-height:1.4;background:#fff;text-transform:uppercase;letter-spacing:0.3px;font-weight:500;}

@media (prefers-color-scheme: dark){
  :root{--bg:#141414;--bg-soft:#1E1E1E;--ink:#F2F2F2;--muted:#A6A6A6;--line:#2C2C2C;--card:#232323;--bubble-bot:#242424;}
  .topbar,.composer,.legal,.reco{background:#181818;}
  .reco{background:#181818;}
  /* Le logo (bleu Leclerc) est un peu terne sur fond sombre : on l'éclaircit. */
  .brand-logo{filter:brightness(1.18);}
  .msg.bot.status{background:#2A1720;border-color:#5D1029;color:#F0C9D2;}
}
