/*
 * Breaky — page /chat/ (préfixe bk-).
 * S'appuie sur le design system (tokens.css, components.css) : aucune couleur en dur, le mode sombre
 * vient de la classe .dark-mode posée sur <html> par theme-init.js.
 */

/* ==================================================================
 * Base
 * ================================================================== */
.bk-html,
.bk {
  height: 100%;
}

.bk {
  margin: 0;
  background: var(--ds-bg);
  color: var(--ds-text);
  font-family: var(--ds-font-body);
  font-size: var(--ds-text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

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

.bk a {
  color: var(--ds-primary-text);
}

/* Boutons du design system posés sur un lien (hors .ds-shell) */
.bk a.ds-btn {
  text-decoration: none;
}

.bk a.ds-btn--primary {
  color: var(--ds-on-primary);
}

.bk a.ds-btn--secondary,
.bk a.ds-btn--ghost {
  color: var(--ds-text);
}

.bk :focus-visible {
  outline: none;
  box-shadow: var(--ds-focus-ring);
}

.bk button {
  font-family: inherit;
}

.bk [hidden] {
  display: none !important;
}

.bk .ds-item__icon--info {
  background: var(--ds-info-soft);
  color: var(--ds-info);
}

.bk-skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--ds-radius-sm);
  background: var(--ds-primary);
  color: var(--ds-on-primary) !important;
  font-weight: 600;
}

.bk-skip:focus {
  top: 12px;
}

.bk-noscript {
  position: fixed;
  inset: auto 16px 16px;
  padding: 16px;
  border-radius: var(--ds-radius-md);
  background: var(--ds-warning-soft);
  color: var(--ds-warning);
  text-align: center;
}

/* Marque de Breaky : étoile blanche sur dégradé teal, point corail */
.bk-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(140deg, #15a6b0, var(--ds-primary) 55%, #016470);
  box-shadow: 0 6px 16px -8px rgba(0, 130, 142, 0.8);
}

.bk-mark svg {
  width: 62%;
  height: 62%;
}

.bk-mark path {
  fill: #ffffff;
}

.bk-mark circle {
  fill: var(--ds-accent);
}

.bk-mark--xl {
  width: 64px;
  height: 64px;
  border-radius: 22px;
}

/* Bouton icône */
.bk-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ds-text-2);
  font-size: 1.05rem;
  cursor: pointer;
  transition: background var(--ds-duration) var(--ds-ease), color var(--ds-duration) var(--ds-ease);
  -webkit-tap-highlight-color: transparent;
}

.bk-icon-btn:hover {
  background: var(--ds-surface-2);
  color: var(--ds-text);
}

.bk-icon-btn.is-on {
  background: var(--ds-danger-soft);
  color: var(--ds-danger);
}

/* ==================================================================
 * Mise en page : barre latérale + zone principale
 * ================================================================== */
.bk-app {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.bk-side {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-3);
  min-height: 0;
  padding: var(--ds-space-4) var(--ds-space-3) var(--ds-space-3);
  background: var(--ds-surface);
  border-right: 1px solid var(--ds-border);
}

.bk-side__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--ds-space-1);
}

.bk-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-3);
  text-decoration: none;
  color: var(--ds-text) !important;
}

.bk-brand__name {
  font-family: var(--ds-font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.bk-side__close {
  display: none;
}

.bk-new {
  min-height: 46px;
}

.bk-search {
  position: relative;
  display: block;
}

.bk-search .cb-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ds-text-3);
  font-size: 0.85rem;
  pointer-events: none;
}

.bk-search input {
  width: 100%;
  height: 42px;
  padding: 0 12px 0 38px;
  border: 1.5px solid transparent;
  border-radius: 14px;
  background: var(--ds-surface-2);
  color: var(--ds-text);
  font: inherit;
  font-size: var(--ds-text-sm);
  -webkit-appearance: none;
  appearance: none;
}

.bk-search input:focus {
  outline: none;
  border-color: var(--ds-primary);
  background: var(--ds-surface);
}

/* Liste des conversations */
.bk-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 calc(var(--ds-space-1) * -1);
  padding: 0 var(--ds-space-1);
  scrollbar-width: thin;
}

.bk-list__group {
  margin: var(--ds-space-4) 0 var(--ds-space-1);
  padding: 0 var(--ds-space-3);
  font-size: var(--ds-text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ds-text-3);
}

.bk-list__group:first-child {
  margin-top: var(--ds-space-1);
}

.bk-chat {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  min-height: 42px;
  padding: 0 4px 0 var(--ds-space-3);
  border-radius: 14px;
  color: var(--ds-text);
  text-decoration: none;
  transition: background var(--ds-duration) var(--ds-ease);
}

.bk-chat:hover,
.bk-chat:focus-within {
  background: var(--ds-surface-2);
}

.bk-chat.is-active {
  background: var(--ds-primary-soft);
}

.bk-chat__link {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding: 10px 0;
  color: inherit !important;
  text-decoration: none;
  font-size: var(--ds-text-sm);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bk-chat.is-active .bk-chat__link {
  font-weight: 600;
  color: var(--ds-primary-text) !important;
}

.bk-chat__pin {
  color: var(--ds-accent);
  font-size: 0.7rem;
}

.bk-chat__more {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  opacity: 0;
}

.bk-chat:hover .bk-chat__more,
.bk-chat.is-active .bk-chat__more,
.bk-chat__more:focus-visible,
.bk-chat__more[aria-expanded="true"] {
  opacity: 1;
}

.bk-list__empty {
  margin: var(--ds-space-6) var(--ds-space-3);
  color: var(--ds-text-3);
  font-size: var(--ds-text-sm);
  text-align: center;
}

.bk-list__skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--ds-space-3);
}

.bk-list__skeleton span {
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--ds-surface-2), var(--ds-surface-hover), var(--ds-surface-2));
  background-size: 200% 100%;
  animation: bk-shimmer 1.4s linear infinite;
}

.bk-list__skeleton span:nth-child(2n) {
  width: 72%;
}

/* Carte « invité » dans la barre latérale */
.bk-guest-card {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-2);
  padding: var(--ds-space-5) var(--ds-space-4);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface-2);
}

.bk-guest-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--ds-accent-soft);
  color: var(--ds-accent-text);
}

.bk-guest-card__title {
  margin: var(--ds-space-2) 0 0;
  font-weight: 600;
}

.bk-guest-card__text {
  margin: 0 0 var(--ds-space-2);
  color: var(--ds-text-2);
  font-size: var(--ds-text-sm);
}

.bk-guest-card .ds-btn {
  min-height: 44px;
}

/* Pied de la barre latérale */
.bk-side__foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-1);
  padding-top: var(--ds-space-2);
  border-top: 1px solid var(--ds-border);
}

.bk-me {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  width: 100%;
  padding: var(--ds-space-2);
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--ds-text);
  text-align: left;
  cursor: pointer;
}

.bk-me:hover {
  background: var(--ds-surface-2);
}

.bk-me__avatar,
.bk-me__icon {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
}

.bk-me__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ds-surface-2);
  color: var(--ds-text-2);
}

.bk-me__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  line-height: 1.3;
}

.bk-me__text strong {
  overflow: hidden;
  font-size: var(--ds-text-sm);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bk-me__text small {
  color: var(--ds-text-3);
  font-size: var(--ds-text-xs);
}

.bk-me__end {
  color: var(--ds-text-3);
}

.bk-side__back {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  padding: var(--ds-space-2) var(--ds-space-3);
  border-radius: 12px;
  color: var(--ds-text-2) !important;
  font-size: var(--ds-text-sm);
  text-decoration: none;
}

.bk-side__back:hover {
  background: var(--ds-surface-2);
  color: var(--ds-text) !important;
}

.bk-scrim {
  display: none;
}

/* ==================================================================
 * Zone principale
 * ================================================================== */
.bk-main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.bk-top {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  height: 64px;
  padding: 0 var(--ds-space-5);
  flex-shrink: 0;
}

.bk-top__menu {
  display: none;
}

.bk-top__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bk-app[data-state="welcome"] .bk-top__title {
  visibility: hidden;
}

.bk-top__actions {
  display: flex;
  align-items: center;
  gap: var(--ds-space-1);
}

.bk-top__cta {
  min-height: 40px;
  margin-right: var(--ds-space-1);
}

/* Menus déroulants */
.bk-menu {
  position: relative;
}

.bk-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 230px;
  padding: 6px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-lg);
  animation: bk-pop 160ms var(--ds-ease) both;
}

.bk-pop button {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ds-text);
  font-size: var(--ds-text-sm);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.bk-pop button .cb-icon {
  width: 18px;
  color: var(--ds-text-3);
  text-align: center;
}

.bk-pop button:hover,
.bk-pop button:focus-visible {
  background: var(--ds-surface-2);
}

.bk-pop button.is-danger,
.bk-pop button.is-danger .cb-icon {
  color: var(--ds-danger);
}

.bk-pop button.is-danger:hover {
  background: var(--ds-danger-soft);
}

.bk-pop--floating {
  position: fixed;
  top: auto;
  right: auto;
  z-index: 120; /* au-dessus du tiroir mobile (90) */
}

/* Zone qui défile */
.bk-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

/* ==================================================================
 * Accueil
 * ================================================================== */
.bk-welcome {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: var(--ds-space-8) var(--ds-space-5) var(--ds-space-6);
  text-align: center;
}

.bk-app[data-state="welcome"] .bk-welcome {
  display: flex;
  animation: bk-rise 500ms var(--ds-ease) both;
}

.bk-app[data-state="welcome"] .bk-thread {
  display: none;
}

.bk-welcome__title {
  margin: var(--ds-space-5) 0 var(--ds-space-2);
  font-family: var(--ds-font-display);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.bk-welcome__name {
  color: var(--ds-primary-text);
}

.bk-welcome__lead {
  max-width: 560px;
  margin: 0 0 var(--ds-space-8);
  color: var(--ds-text-2);
}

.bk-starters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ds-space-3);
  width: 100%;
}

.bk-starter {
  display: flex;
  align-items: flex-start;
  gap: var(--ds-space-3);
  padding: var(--ds-space-4);
  border: 1.5px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface);
  color: var(--ds-text);
  text-align: left;
  cursor: pointer;
  transition: transform var(--ds-duration) var(--ds-ease), border-color var(--ds-duration) var(--ds-ease), box-shadow var(--ds-duration) var(--ds-ease);
  animation: bk-rise 500ms var(--ds-ease) both;
}

.bk-starter:nth-child(2) { animation-delay: 60ms; }
.bk-starter:nth-child(3) { animation-delay: 120ms; }
.bk-starter:nth-child(4) { animation-delay: 180ms; }

.bk-starter:hover {
  transform: translateY(-2px);
  border-color: var(--ds-border-strong);
  box-shadow: var(--ds-shadow-md);
}

.bk-starter__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--ds-primary-soft);
  color: var(--ds-primary-text);
}

.bk-starter__icon--accent { background: var(--ds-accent-soft); color: var(--ds-accent-text); }
.bk-starter__icon--success { background: var(--ds-success-soft); color: var(--ds-success); }
.bk-starter__icon--info { background: var(--ds-info-soft); color: var(--ds-info); }
.bk-starter__icon--warning { background: var(--ds-warning-soft); color: var(--ds-warning); }

.bk-starter__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.bk-starter__text strong {
  font-size: var(--ds-text-sm);
  font-weight: 600;
}

.bk-starter__text small {
  margin-top: 3px;
  color: var(--ds-text-3);
  font-size: var(--ds-text-xs);
}

.bk-welcome__quota {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: var(--ds-space-6) 0 0;
  color: var(--ds-text-2);
  font-size: var(--ds-text-sm);
}

.bk-welcome__quota .cb-icon {
  color: var(--ds-accent);
}

/* ==================================================================
 * Fil de la conversation
 * ================================================================== */
.bk-thread {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-8);
  max-width: 800px;
  margin: 0 auto;
  padding: var(--ds-space-4) var(--ds-space-5) var(--ds-space-10);
}

.bk-msg {
  display: flex;
  gap: var(--ds-space-3);
  animation: bk-rise 360ms var(--ds-ease) both;
}

.bk-msg--user {
  flex-direction: column;
  align-items: flex-end;
  gap: var(--ds-space-2);
}

.bk-bubble {
  max-width: min(600px, 88%);
  padding: 12px 18px;
  border-radius: 22px 22px 8px 22px;
  background: var(--ds-primary-soft);
  color: var(--ds-text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bk-msg__photo {
  width: 220px;
  max-width: 70%;
  border-radius: 20px;
  border: 1px solid var(--ds-border);
  object-fit: cover;
  aspect-ratio: 4 / 3;
  background: var(--ds-surface-2);
}

.bk-fridge-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: min(600px, 88%);
}

.bk-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--ds-primary-soft);
  color: var(--ds-primary-text);
  font-size: var(--ds-text-sm);
  font-weight: 500;
  animation: bk-pop 280ms var(--ds-ease) both;
}

.bk-tag .cb-icon {
  font-size: 0.7rem;
  opacity: 0.8;
}

.bk-msg--bot .bk-mark {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  margin-top: 2px;
}

.bk-msg__body {
  flex: 1;
  min-width: 0;
}

/* Statut (recherche, analyse) et indicateur d'écriture */
.bk-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  color: var(--ds-text-2);
  font-size: var(--ds-text-sm);
  font-weight: 500;
}

.bk-status__text {
  background: linear-gradient(90deg, var(--ds-text-2) 30%, var(--ds-primary-text) 50%, var(--ds-text-2) 70%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: bk-shimmer 1.6s linear infinite;
}

.bk-typing {
  display: inline-flex;
  gap: 5px;
  padding: 12px 0;
}

.bk-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ds-text-3);
  animation: bk-blink 1.2s infinite both;
}

.bk-typing span:nth-child(2) { animation-delay: 0.15s; }
.bk-typing span:nth-child(3) { animation-delay: 0.3s; }

.bk-error {
  display: flex;
  align-items: flex-start;
  gap: var(--ds-space-3);
  padding: var(--ds-space-3) var(--ds-space-4);
  border-radius: var(--ds-radius-md);
  background: var(--ds-danger-soft);
  color: var(--ds-danger);
  font-size: var(--ds-text-sm);
}

.bk-error .ds-btn {
  margin-left: auto;
  min-height: 34px;
  padding: 0 12px;
}

/* ==================================================================
 * Texte Markdown des réponses
 * ================================================================== */
.bk-md {
  overflow-wrap: anywhere;
  font-size: 0.97rem;
}

.bk-md > :first-child {
  margin-top: 0;
}

.bk-md > :last-child {
  margin-bottom: 0;
}

.bk-md p {
  margin: 0 0 0.85em;
}

.bk-md h1,
.bk-md h2,
.bk-md h3,
.bk-md h4 {
  margin: 1.4em 0 0.5em;
  font-family: var(--ds-font-body);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
}

.bk-md h1,
.bk-md h2 {
  font-size: 1.15rem;
}

.bk-md ul,
.bk-md ol {
  margin: 0 0 1em;
  padding-left: 1.4em;
}

.bk-md li {
  margin: 0.3em 0;
  padding-left: 0.2em;
}

.bk-md li::marker {
  color: var(--ds-primary-text);
  font-weight: 600;
}

.bk-md strong {
  font-weight: 600;
}

.bk-md a {
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.bk-md blockquote {
  margin: 0 0 1em;
  padding: 10px 16px;
  border-left: 4px solid var(--ds-accent);
  border-radius: 0 14px 14px 0;
  background: var(--ds-accent-soft);
  color: var(--ds-text);
}

.bk-md blockquote p:last-child {
  margin: 0;
}

.bk-md code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--ds-surface-2);
  font-size: 0.88em;
}

.bk-md pre {
  overflow-x: auto;
  padding: 14px;
  border-radius: 14px;
  background: var(--ds-surface-2);
}

.bk-md pre code {
  padding: 0;
  background: none;
}

.bk-md hr {
  margin: 1.4em 0;
  border: 0;
  border-top: 1px solid var(--ds-border);
}

.bk-md .bk-tail {
  white-space: pre-wrap;
}

/* Tableaux : ascenseur horizontal + bouton plein écran */
.bk-table {
  position: relative;
  margin: 0 0 1em;
  border: 1px solid var(--ds-border);
  border-radius: 16px;
  background: var(--ds-surface);
}

.bk-table__scroll {
  overflow-x: auto;
  border-radius: 16px;
}

.bk-md table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--ds-text-sm);
}

.bk-md th,
.bk-md td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--ds-border);
  text-align: left;
  vertical-align: top;
}

.bk-md th {
  background: var(--ds-surface-2);
  font-weight: 600;
  white-space: nowrap;
}

.bk-md tr:last-child td {
  border-bottom: 0;
}

.bk-table__expand {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  width: 30px;
  height: 30px;
  border: 1px solid var(--ds-border);
  border-radius: 10px;
  background: var(--ds-surface);
  color: var(--ds-text-2);
  font-size: 0.75rem;
  cursor: pointer;
  box-shadow: var(--ds-shadow-sm);
}

/* ==================================================================
 * Cartes recettes, relances, actions
 * ================================================================== */
.bk-cards {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(200px, 232px);
  gap: var(--ds-space-3);
  margin: var(--ds-space-4) 0 0;
  padding: 2px 2px var(--ds-space-3);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.bk-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface);
  color: var(--ds-text) !important;
  text-decoration: none;
  scroll-snap-align: start;
  transition: transform var(--ds-duration) var(--ds-ease), box-shadow var(--ds-duration) var(--ds-ease);
  animation: bk-rise 420ms var(--ds-ease) both;
}

.bk-card:nth-child(2) { animation-delay: 70ms; }
.bk-card:nth-child(3) { animation-delay: 140ms; }
.bk-card:nth-child(4) { animation-delay: 210ms; }

.bk-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--ds-shadow-md);
}

.bk-card__img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--ds-surface-2);
}

.bk-card__img--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ds-text-3);
  font-size: 1.6rem;
}

.bk-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px 14px;
}

.bk-card__title {
  display: -webkit-box;
  overflow: hidden;
  font-size: var(--ds-text-sm);
  font-weight: 600;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.bk-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: auto;
  color: var(--ds-text-2);
  font-size: var(--ds-text-xs);
}

.bk-card__meta .cb-icon {
  margin-right: 3px;
  color: var(--ds-text-3);
}

.bk-card__meta .bk-star {
  color: var(--ds-accent);
}

.bk-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-2);
  margin-top: var(--ds-space-4);
}

.bk-suggest button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1.5px solid var(--ds-border);
  border-radius: 14px;
  background: var(--ds-surface);
  color: var(--ds-text);
  font-size: var(--ds-text-sm);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--ds-duration) var(--ds-ease), background var(--ds-duration) var(--ds-ease);
  animation: bk-rise 360ms var(--ds-ease) both;
}

.bk-suggest button:hover {
  border-color: var(--ds-primary);
  background: var(--ds-primary-soft);
}

.bk-suggest button .cb-icon {
  color: var(--ds-primary-text);
  font-size: 0.75rem;
}

.bk-actions {
  display: flex;
  gap: 2px;
  margin: var(--ds-space-2) 0 0 -8px;
}

.bk-actions .bk-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--ds-text-3);
}

.bk-actions .bk-icon-btn:hover {
  color: var(--ds-text);
}

.bk-actions .bk-icon-btn.is-picked {
  color: var(--ds-primary-text);
  background: var(--ds-primary-soft);
}

/* Bouton « revenir en bas » */
.bk-jump {
  position: absolute;
  left: 50%;
  bottom: 200px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border: 1px solid var(--ds-border);
  border-radius: 14px;
  background: var(--ds-surface);
  color: var(--ds-text-2);
  box-shadow: var(--ds-shadow-md);
  cursor: pointer;
  transform: translateX(-50%);
  animation: bk-pop 200ms var(--ds-ease) both;
}

/* ==================================================================
 * Zone de saisie
 * ================================================================== */
.bk-dock {
  flex-shrink: 0;
  padding: 0 var(--ds-space-5) calc(var(--ds-space-3) + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to bottom, transparent, var(--ds-bg) 28px);
}

.bk-composer {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
  padding: var(--ds-space-2) var(--ds-space-2) var(--ds-space-2);
  border: 1.5px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-md);
  transition: border-color var(--ds-duration) var(--ds-ease), box-shadow var(--ds-duration) var(--ds-ease);
}

.bk-composer:focus-within {
  border-color: var(--ds-border-strong);
}

/* Bouton « + » (photo) et sélecteur de mode */
.bk-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1.5px solid var(--ds-border);
  border-radius: 14px;
  background: transparent;
  color: var(--ds-text);
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--ds-duration) var(--ds-ease), border-color var(--ds-duration) var(--ds-ease);
  -webkit-tap-highlight-color: transparent;
}

.bk-plus:hover {
  background: var(--ds-surface-2);
  border-color: var(--ds-border-strong);
}

.bk-modesel {
  min-width: 0;
}

.bk-modesel__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ds-text-2);
  font-size: 0.86rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--ds-duration) var(--ds-ease), color var(--ds-duration) var(--ds-ease);
  -webkit-tap-highlight-color: transparent;
}

.bk-modesel__btn:hover,
.bk-modesel__btn[aria-expanded="true"] {
  background: var(--ds-surface-2);
  color: var(--ds-text);
}

.bk-modesel__btn.is-set {
  background: var(--ds-primary-soft);
  color: var(--ds-primary-text);
  font-weight: 600;
}

.bk-modesel__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bk-modesel__chev {
  font-size: 0.62rem;
  opacity: 0.7;
  transition: transform var(--ds-duration) var(--ds-ease);
}

.bk-modesel__btn[aria-expanded="true"] .bk-modesel__chev {
  transform: rotate(180deg);
}

/* Liste des modes : s'ouvre au-dessus de la zone de saisie */
.bk-pop.bk-modemenu {
  top: auto;
  right: auto;
  left: 8px;
  bottom: calc(100% + 8px);
  width: min(330px, calc(100% - 16px));
  transform-origin: bottom left;
}

.bk-pop .bk-modeopt {
  gap: 12px;
  padding: 8px 10px;
  border-radius: 14px;
}

.bk-modeopt__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--ds-surface-2);
}

.bk-pop .bk-modeopt__icon .cb-icon {
  width: auto;
  color: inherit;
  font-size: 1.15rem;
}

.bk-starter__icon,
.bk-guest-card__icon,
.bk-me__icon {
  font-size: 1.3rem;
}

.bk-modesel__ico {
  display: inline-flex;
}

.bk-modeopt__icon--auto { background: var(--ds-primary-soft); color: var(--ds-primary-text); }
.bk-modeopt__icon--recipes { background: var(--ds-accent-soft); color: var(--ds-accent-text); }
.bk-modeopt__icon--fridge { background: var(--ds-info-soft); color: var(--ds-info); }
.bk-modeopt__icon--photo { background: var(--ds-warning-soft); color: var(--ds-warning); }
.bk-modeopt__icon--plan { background: var(--ds-success-soft); color: var(--ds-success); }
.bk-modeopt__icon--help { color: var(--ds-text-2); }

.bk-modeopt__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.bk-modeopt__text strong {
  font-weight: 600;
}

.bk-modeopt__text small {
  color: var(--ds-text-3);
  font-size: var(--ds-text-xs);
  font-weight: 400;
}

.bk-pop .bk-modeopt__end {
  width: auto;
  font-size: 0.75rem;
}

.bk-pop .bk-modeopt__check {
  color: var(--ds-primary-text);
  visibility: hidden;
}

.bk-modeopt[aria-checked="true"] {
  background: var(--ds-surface-2);
}

.bk-pop .bk-modeopt[aria-checked="true"] .bk-modeopt__check {
  visibility: visible;
}

.bk-modeopt.is-locked .bk-modeopt__text strong {
  color: var(--ds-text-2);
}

.bk-attach {
  padding: 10px 10px 2px;
}

.bk-attach__item {
  position: relative;
  display: inline-block;
  margin: 0;
}

.bk-attach__item img {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid var(--ds-border);
}

.bk-attach__remove {
  position: absolute;
  top: -8px;
  right: -8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  line-height: 1;
  border: 2px solid var(--ds-surface);
  border-radius: 50%;
  background: var(--ds-text);
  color: var(--ds-surface);
  font-size: 0.7rem;
  cursor: pointer;
}

.bk-fridge-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
}

.bk-fridge-line .bk-tag {
  animation: none;
}

.bk-fridge-line button {
  padding: 6px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ds-primary-text);
  font-size: var(--ds-text-sm);
  font-weight: 600;
  cursor: pointer;
}

.bk-input {
  display: block;
  width: 100%;
  min-height: 44px;
  max-height: 220px;
  padding: 10px 10px 6px;
  border: 0;
  background: transparent;
  color: var(--ds-text);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  resize: none;
}

.bk-input:focus {
  outline: none;
  box-shadow: none !important;
}

.bk-input::placeholder {
  color: var(--ds-text-3);
}

.bk-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bk-tools__hint {
  flex: 1;
  min-width: 0;
  padding: 0 var(--ds-space-2);
  overflow: hidden;
  color: var(--ds-text-3);
  font-size: var(--ds-text-xs);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bk-tools__hint.is-warn {
  color: var(--ds-warning);
}

.bk-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 15px;
  background: var(--ds-primary);
  color: var(--ds-on-primary);
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--ds-duration) var(--ds-ease), transform var(--ds-duration) var(--ds-ease), opacity var(--ds-duration) var(--ds-ease);
}

.bk-send:hover {
  background: var(--ds-primary-hover);
}

.bk-send:active {
  transform: scale(0.94);
}

.bk-send:disabled {
  opacity: 0.35;
  cursor: default;
}

.bk-send.is-stop {
  background: var(--ds-text);
  color: var(--ds-surface);
}

.bk-dock__note {
  margin: var(--ds-space-2) 0 0;
  color: var(--ds-text-3);
  font-size: 0.72rem;
  text-align: center;
}

/* Glisser-déposer une photo */
.bk-drop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ds-space-6);
  background: var(--ds-overlay);
  backdrop-filter: blur(4px);
}

.bk-drop__box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ds-space-2);
  padding: var(--ds-space-10) var(--ds-space-12);
  border: 2px dashed var(--ds-primary);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-surface);
  color: var(--ds-text);
  animation: bk-pop 220ms var(--ds-ease) both;
}

.bk-drop__box .cb-icon {
  color: var(--ds-primary-text);
  font-size: 2rem;
}

.bk-drop__box p {
  margin: 0;
  font-weight: 600;
}

.bk-drop__box small {
  color: var(--ds-text-3);
}

/* ==================================================================
 * Fenêtres (réglages, frigo, tableau)
 * ================================================================== */
.bk-modal--wide {
  width: min(560px, calc(100vw - 32px));
}

.bk-modal__input {
  margin-top: var(--ds-space-4);
  text-align: left;
}

.bk-sheet {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-4);
  padding: var(--ds-space-6);
}

.bk-sheet__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ds-space-3);
}

.bk-sheet__title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: var(--ds-font-display);
  font-size: 1.2rem;
  font-weight: 600;
}

.bk-sheet__title .cb-icon {
  color: var(--ds-primary-text);
}

.bk-sheet__lead {
  margin: 6px 0 0;
  color: var(--ds-text-2);
  font-size: var(--ds-text-sm);
}

.bk-sheet .ds-list {
  margin: 0 calc(var(--ds-space-6) * -1);
}

.bk-sheet .ds-item {
  padding-left: var(--ds-space-6);
  padding-right: var(--ds-space-6);
}

.bk-sheet__foot {
  margin: 0;
  color: var(--ds-text-3);
  font-size: var(--ds-text-xs);
  text-align: center;
}

.bk-sheet__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--ds-space-2);
}

.bk-google {
  width: 100%;
  border: 1.5px solid var(--ds-border-strong);
  background: var(--ds-surface);
  color: var(--ds-text) !important;
}

/* Frigo */
.bk-fridge__chosen {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 8px;
}

.bk-fridge__chosen .bk-tag {
  padding-right: 6px;
}

.bk-fridge__chosen .bk-tag button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.bk-fridge__chosen .bk-tag button:hover {
  background: var(--ds-surface);
}

.bk-fridge__tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.bk-fridge__tabs button {
  flex-shrink: 0;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: var(--ds-surface-2);
  color: var(--ds-text-2);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}

.bk-fridge__tabs button[aria-selected="true"] {
  background: var(--ds-primary-soft);
  color: var(--ds-primary-text);
  font-weight: 600;
}

.bk-fridge__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
}

.bk-fridge__grid button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1.5px solid var(--ds-border);
  border-radius: 14px;
  background: var(--ds-surface);
  color: var(--ds-text);
  font-size: var(--ds-text-sm);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--ds-duration) var(--ds-ease), background var(--ds-duration) var(--ds-ease);
}

.bk-fridge__grid button:hover {
  border-color: var(--ds-border-strong);
}

.bk-fridge__grid button[aria-pressed="true"] {
  border-color: var(--ds-primary);
  background: var(--ds-primary-soft);
  color: var(--ds-primary-text);
  font-weight: 600;
}

/* Tableau plein écran */
.bk-table-view {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--ds-bg);
  color: var(--ds-text);
  font-family: var(--ds-font-body);
}

.bk-table-view[open] {
  display: flex;
  flex-direction: column;
}

.bk-table-view__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ds-space-3) var(--ds-space-4);
  border-bottom: 1px solid var(--ds-border);
  font-weight: 600;
}

.bk-table-view__body {
  flex: 1;
  overflow: auto;
  padding: var(--ds-space-4);
}

/* ==================================================================
 * Animations
 * ================================================================== */
@keyframes bk-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes bk-pop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes bk-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@keyframes bk-blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ==================================================================
 * Tablette et mobile
 * ================================================================== */
@media (max-width: 900px) {
  .bk-app {
    grid-template-columns: minmax(0, 1fr);
  }

  .bk-side {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 90;
    width: min(320px, 86vw);
    padding-top: calc(var(--ds-space-4) + env(safe-area-inset-top, 0px));
    padding-bottom: calc(var(--ds-space-3) + env(safe-area-inset-bottom, 0px));
    border-radius: 0 var(--ds-radius-lg) var(--ds-radius-lg) 0;
    box-shadow: none;
    transform: translateX(-105%);
    transition: transform 320ms var(--ds-ease), box-shadow 320ms var(--ds-ease), visibility 0s linear 320ms;
    visibility: hidden;
  }

  .bk-app.is-side-open .bk-side {
    box-shadow: var(--ds-shadow-lg);
    transform: none;
    visibility: visible;
    transition: transform 320ms var(--ds-ease), box-shadow 320ms var(--ds-ease), visibility 0s;
  }

  .bk-side__close,
  .bk-top__menu {
    display: inline-flex;
  }

  .bk-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 80;
    background: var(--ds-overlay);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 320ms var(--ds-ease), visibility 0s linear 320ms;
  }

  .bk-app.is-side-open .bk-scrim {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    transition: opacity 320ms var(--ds-ease), visibility 0s;
  }

  .bk-chat__more {
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .bk-top {
    height: 56px;
    padding: 0 var(--ds-space-2);
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(56px + env(safe-area-inset-top, 0px));
  }

  .bk-top__cta span {
    display: none;
  }

  .bk-top__cta {
    width: 40px;
    padding: 0;
  }

  .bk-thread {
    gap: var(--ds-space-6);
    padding: var(--ds-space-2) var(--ds-space-4) var(--ds-space-8);
  }

  .bk-msg--bot {
    flex-direction: column;
    gap: var(--ds-space-2);
  }

  .bk-msg--bot .bk-mark {
    width: 28px;
    height: 28px;
    border-radius: 10px;
  }

  .bk-welcome {
    justify-content: flex-start;
    padding: var(--ds-space-6) var(--ds-space-4) var(--ds-space-4);
  }

  .bk-welcome__lead {
    margin-bottom: var(--ds-space-6);
    font-size: var(--ds-text-sm);
  }

  .bk-starters {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--ds-space-2);
  }

  .bk-starter {
    padding: var(--ds-space-3);
    align-items: center;
  }

  .bk-dock {
    padding: 0 var(--ds-space-2) max(var(--ds-space-2), calc(env(safe-area-inset-bottom, 0px) - 18px));
  }

  .bk-composer {
    border-radius: 24px;
  }

  .bk-dock__note {
    display: none;
  }

  .bk-sheet {
    padding: var(--ds-space-5) var(--ds-space-4) calc(var(--ds-space-6) + env(safe-area-inset-bottom, 0px));
  }

  .bk-sheet .ds-list {
    margin: 0 calc(var(--ds-space-4) * -1);
  }

  .bk-sheet .ds-item {
    padding-left: var(--ds-space-4);
    padding-right: var(--ds-space-4);
  }

  .bk-modal--wide {
    width: 100%;
  }

  .bk-jump {
    bottom: 170px;
  }
}

@media (hover: none) {
  .bk-chat__more {
    opacity: 1;
  }
}

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