/* ==========================================================================
   Chat View & Message Bubbles (Material Design 3 Expressive)
   Strict Zero-Emoji Policy
   ========================================================================== */

#chatFeed{
  display:flex;
  flex-direction:column;
  gap:16px;
  overflow-y:auto;
  flex:1;
  padding:12px 0;
  min-height:100px;
  overscroll-behavior-y:contain;
}

.msg{
  display:flex;
  flex-direction:column;
  max-width:85%;
  border-radius:var(--md-sys-shape-corner-large-increased);
  padding:12px 18px;
  font:var(--md-sys-typescale-body-large);
  line-height:1.5;
  box-sizing:border-box;
}

.msg.msg-new{
  animation:modalIn .18s var(--md-sys-motion-spring-fast);
}

/* User Message Bubble (M3 Primary Container + Asymmetric Shape) */
.msg.user{
  align-self:flex-end;
  background:var(--md-sys-color-primary-container);
  color:var(--md-sys-color-on-primary-container);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:20px 20px 4px 20px;
  box-shadow:var(--md-sys-elevation-level1);
}
.msg.user .who{
  font:var(--md-sys-typescale-label-small-emphasized);
  color:var(--md-sys-color-on-primary-container);
  opacity:0.9;
  text-transform:uppercase;
  margin-bottom:3px;
  letter-spacing:0.04em;
}

/* Assistant Message Bubble (M3 Surface Container High + Asymmetric Shape) */
.msg.hermes, .msg.local, .msg.webllm, .msg.assistant{
  align-self:flex-start;
  background:var(--md-sys-color-surface-container-high);
  color:var(--md-sys-color-on-surface);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:20px 20px 20px 4px;
  box-shadow:var(--md-sys-elevation-level1);
}
.msg.hermes .who, .msg.local .who, .msg.webllm .who, .msg.assistant .who{
  font:var(--md-sys-typescale-label-small-emphasized);
  color:var(--md-sys-color-on-surface-variant);
  text-transform:uppercase;
  margin-bottom:3px;
  letter-spacing:0.04em;
}

.msg.hermes a, .msg.local a, .msg.webllm a, .msg.assistant a{
  color:var(--md-sys-color-primary);
  text-decoration:underline;
  font-weight:500;
}
.msg.hermes code, .msg.local code, .msg.webllm code, .msg.assistant code{
  background:var(--md-sys-color-surface-container-lowest);
  color:var(--md-sys-color-on-surface);
  border:1px solid var(--md-sys-color-outline-variant);
  padding:2px 6px;
  border-radius:var(--md-sys-shape-corner-extra-small);
  font-size:13px;
}
.msg.hermes .chat-actions-container, .msg.local .chat-actions-container, .msg.webllm .chat-actions-container, .msg.assistant .chat-actions-container{
  border-top:1px solid var(--md-sys-color-outline-variant);
}
.msg.hermes .chat-action-badge, .msg.local .chat-action-badge, .msg.webllm .chat-action-badge, .msg.assistant .chat-action-badge{
  background:var(--md-sys-color-surface-container-low);
  border:1px solid var(--md-sys-color-outline-variant);
  color:var(--md-sys-color-on-surface);
}
.msg.hermes .chat-action-badge:hover, .msg.local .chat-action-badge:hover, .msg.webllm .chat-action-badge:hover, .msg.assistant .chat-action-badge:hover{
  background:var(--md-sys-color-surface-container-highest);
  border-color:var(--md-sys-color-outline);
}

.msg .body{
  white-space:pre-wrap;
  word-break:break-word;
}

/* M3 Date Dividers */
.chat-date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 18px 0 14px;
  position: relative;
  width: 100%;
}
.chat-date-divider::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  height: 1px;
  background: var(--md-sys-color-outline-variant);
  z-index: 1;
}
.chat-date-divider-pill {
  position: relative;
  z-index: 2;
  padding: 4px 14px;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-small-emphasized);
  letter-spacing: 0.02em;
  box-shadow: var(--md-sys-elevation-level1);
  border: 1px solid var(--md-sys-color-outline-variant);
}

/* M3 Expressive Typing Indicator */
.msg.msg-typing {
  min-width: 64px;
}
.msg.msg-typing .body {
  display: flex;
  align-items: center;
  padding: 4px 2px;
}
.chat-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
}
.chat-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--md-sys-color-primary);
  opacity: 0.4;
  animation: chatDotBounce 1.4s cubic-bezier(0.2, 0, 0, 1) infinite;
}
.chat-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.chat-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes chatDotBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* Badges d'actions interactifs (M3 Action Confirmation Cards) */
.chat-actions-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

.chat-action-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  font: var(--md-sys-typescale-label-medium);
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-level1);
  transition: all var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects);
}

.chat-action-badge:hover {
  background: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-outline);
  transform: translateY(-1px);
  box-shadow: var(--md-sys-elevation-level2);
}

.chat-action-badge:active {
  transform: scale(0.96);
}

.chat-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.chat-action-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chat-action-dot.create {
  background: var(--md-sys-color-tertiary);
  box-shadow: 0 0 6px rgba(var(--md-sys-color-tertiary-rgb, 13, 148, 136), 0.4);
}
.chat-action-dot.update {
  background: var(--md-sys-color-primary);
  box-shadow: 0 0 6px var(--accent-glow);
}
.chat-action-dot.delete {
  background: var(--md-sys-color-error);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

/* ==========================================================================
   Chat Layout, Sessions Drawer, Side Actions & Interaction Bars
   ========================================================================== */

#panel-chat {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  overflow: hidden;
}

.chat-panel-inner {
  flex: 1;
  min-width: 0;
  height: 100% !important;
  max-width: 840px !important;
  margin: 0 auto !important;
  padding-left: 76px !important;
  padding-right: 20px !important;
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
  gap: 0 !important;
  box-sizing: border-box !important;
  transition: padding-left 0.28s ease, max-width 0.28s ease;
}

#panel-chat.drawer-open .chat-panel-inner {
  padding-left: 20px !important;
  padding-right: 20px !important;
}

/* Bouton toggle dedie M3 Icon Button */
.chat-sessions-toggle-btn {
  position: absolute;
  left: 20px;
  top: 20px;
  z-index: 55;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-fast);
  box-shadow: var(--md-sys-elevation-level1);
}
.chat-sessions-toggle-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  pointer-events: none;
  transition: transform var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-fast);
}

.chat-sessions-toggle-btn .chat-toggle-icon-pinned {
  display: none;
}

.chat-sessions-toggle-btn.pinned .chat-toggle-icon-default {
  display: none;
}

.chat-sessions-toggle-btn.pinned .chat-toggle-icon-pinned {
  display: inline-block;
  animation: pinIconIn 0.22s var(--md-sys-motion-spring-fast);
}

@keyframes pinIconIn {
  from {
    transform: scale(0.6) rotate(-35deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}
.chat-sessions-toggle-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 48px;
  min-height: 48px;
  width: 100%;
  height: 100%;
}

.chat-sessions-toggle-btn:hover,
.chat-sessions-toggle-btn.active,
.chat-sessions-toggle-btn.pinned {
  background: var(--md-sys-color-surface-container-high);
  border-color: var(--md-sys-color-outline);
  transform: scale(1.05);
  box-shadow: var(--md-sys-elevation-level2);
}

.chat-sessions-toggle-btn.pinned {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.chat-unread-badge-count {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 8px;
  height: 8px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary);
  box-shadow: 0 0 6px var(--accent-glow);
}

/* Panneau latéral des discussions flottant (M3 Floating Navigation Drawer) */
.chat-sessions-drawer {
  position: relative;
  width: 0;
  min-width: 0;
  height: calc(100% - 24px);
  max-height: calc(100% - 24px);
  margin: 12px 0 12px 0;
  border-radius: var(--md-sys-shape-corner-extra-large, 24px);
  background: var(--md-sys-color-surface-container);
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow: hidden;
  flex-shrink: 0;
  opacity: 0;
  pointer-events: none;
  box-sizing: border-box;
  transition: width 0.28s var(--md-sys-motion-spring-default),
              margin 0.28s var(--md-sys-motion-spring-default),
              opacity 0.2s ease,
              border-color 0.28s ease,
              box-shadow 0.28s ease;
}

.chat-sessions-drawer.revealed,
.chat-sessions-drawer.pinned-open {
  width: 280px;
  min-width: 280px;
  margin: 12px 0 12px 12px;
  opacity: 1;
  pointer-events: auto;
  border-color: var(--md-sys-color-outline-variant);
  box-shadow: var(--md-sys-elevation-level3);
}

.chat-sessions-drawer-header,
.chat-sessions-list-wrap,
.chat-sessions-list {
  width: 280px;
  box-sizing: border-box;
}

.chat-sessions-drawer-header {
  padding: 12px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.chat-sessions-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 48px;
  min-height: 40px;
}

.chat-sessions-heading {
  font: var(--md-sys-typescale-title-small-emphasized);
  color: var(--md-sys-color-on-surface);
  letter-spacing: -0.01em;
}

.chat-sessions-close-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--md-sys-shape-corner-full);
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short2) ease;
}
.chat-sessions-close-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 48px;
  min-height: 48px;
  width: 100%;
  height: 100%;
}

.chat-sessions-close-btn:hover {
  background: rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
  color: var(--md-sys-color-on-surface);
}

.chat-sessions-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.chat-sessions-search-wrap svg {
  position: absolute;
  left: 12px;
  color: var(--md-sys-color-on-surface-variant);
  pointer-events: none;
}

.chat-sessions-search-input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-body-medium);
  outline: none;
  box-sizing: border-box;
  transition: border-color var(--md-sys-motion-duration-short2) ease;
}

.chat-sessions-search-input:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

/* Liste des sessions (M3 Navigation Drawer Items) */
.chat-sessions-list-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

.chat-sessions-scroll-fade {
  position: absolute;
  left: 0;
  right: 0;
  height: 28px;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-effects);
}

.chat-sessions-scroll-fade-top {
  top: 0;
  background: linear-gradient(to bottom, var(--md-sys-color-surface-container-low) 0%, rgba(0, 0, 0, 0) 100%);
}

.chat-sessions-scroll-fade-bottom {
  bottom: 0;
  background: linear-gradient(to top, var(--md-sys-color-surface-container-low) 0%, rgba(0, 0, 0, 0) 100%);
}

.chat-sessions-list-wrap.can-scroll-up .chat-sessions-scroll-fade-top {
  opacity: 1;
}

.chat-sessions-list-wrap.can-scroll-down .chat-sessions-scroll-fade-bottom {
  opacity: 1;
}

.chat-sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--md-sys-shape-corner-full);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  transition: all var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects);
  position: relative;
}

.chat-session-item:hover {
  background: rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}

.chat-session-item.active {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.chat-session-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary);
  box-shadow: 0 0 6px var(--accent-glow);
  flex-shrink: 0;
}

.session-item-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-item-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.session-item-title {
  font: var(--md-sys-typescale-title-small);
  color: var(--md-sys-color-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-session-item.active .session-item-title {
  font: var(--md-sys-typescale-title-small-emphasized);
  color: var(--md-sys-color-on-secondary-container);
}
.chat-session-item.active .session-item-date {
  color: var(--md-sys-color-on-secondary-container);
  opacity: 0.8;
}
.chat-session-item.active .session-item-preview {
  color: var(--md-sys-color-on-secondary-container);
  opacity: 0.9;
}

.session-item-date {
  font: var(--md-sys-typescale-label-small);
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
  flex-shrink: 0;
}

.session-item-preview {
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.85;
}

.session-item-actions {
  display: none;
  align-items: center;
  gap: 4px;
}

.chat-session-item:hover .session-item-actions {
  display: flex;
}

.session-item-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--md-sys-shape-corner-full);
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short2) ease;
}

.session-item-action-btn:hover {
  background: rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
  color: var(--md-sys-color-on-surface);
}

.session-item-action-btn.delete:hover {
  color: var(--md-sys-color-error);
}

/* Section archives repliable dans le volet */
.chat-archived-section-divider {
  padding: 12px 4px 4px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  margin-top: 6px;
}

.chat-archived-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: transparent;
  border: none;
  font: var(--md-sys-typescale-label-medium);
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short2) ease;
}

.chat-archived-toggle-btn:hover {
  background: rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
  color: var(--md-sys-color-on-surface);
}

.chat-archived-sessions-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

/* Barre d'actions verticales à droite de la page */
.chat-right-actions-bar {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: calc(100% - 32px);
  margin: 16px 16px 16px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 40;
  pointer-events: none;
}

.chat-right-top-actions,
.chat-timeline-nav,
.chat-side-action-btn {
  pointer-events: auto;
}

.chat-right-top-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  width: 100%;
  align-items: center;
}

/* M3 Tonal Side Action Buttons */
.chat-side-action-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-fast);
  box-shadow: var(--md-sys-elevation-level1);
}
.chat-side-action-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.chat-side-action-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 48px;
  min-height: 48px;
  width: 100%;
  height: 100%;
}

.chat-side-action-btn:hover {
  background: var(--md-sys-color-surface-container-high);
  border-color: var(--md-sys-color-outline);
  transform: scale(1.06);
  box-shadow: var(--md-sys-elevation-level2);
}

.chat-side-action-btn:active {
  transform: scale(0.95);
}

.chat-side-action-btn.active {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.chat-side-action-btn.delete:hover {
  color: var(--md-sys-color-error);
  border-color: var(--md-sys-color-error);
}

/* En-tête de sujet discret */
.chat-topic-header {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  padding: 12px 0 4px;
  flex-shrink: 0;
}

.chat-topic-header .chat-current-title {
  font: var(--md-sys-typescale-title-small-emphasized);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--md-sys-shape-corner-small);
  transition: background var(--md-sys-motion-duration-short2) ease;
}

.chat-topic-header .chat-current-title:hover {
  background: rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}

.chat-topic-header .chat-current-date {
  font: var(--md-sys-typescale-label-small);
  color: var(--md-sys-color-on-surface-variant);
}

/* Zone principale & Minimap Timeline */
.chat-main-area {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  position: relative;
  overflow: hidden;
}

.chat-scroll-fade {
  position: absolute;
  left: 0;
  right: 0;
  height: 32px;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-effects);
}

.chat-scroll-fade-top {
  top: 0;
  background: linear-gradient(to bottom, var(--md-sys-color-surface) 0%, rgba(0, 0, 0, 0) 100%);
}

.chat-scroll-fade-bottom {
  bottom: 0;
  background: linear-gradient(to top, var(--md-sys-color-surface) 0%, rgba(0, 0, 0, 0) 100%);
}

.chat-main-area.can-scroll-up .chat-scroll-fade-top {
  opacity: 1;
}

.chat-main-area.can-scroll-down .chat-scroll-fade-bottom {
  opacity: 1;
}

.chat-main-area #chatFeed {
  padding-right: 0;
  padding-left: 0;
}

/* Minimap / Timeline Scrubber avec barres horizontales centré dans la barre de droite */
.chat-timeline-nav {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  max-height: calc(100% - 170px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}

.chat-timeline-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  max-height: 100%;
  overflow-y: auto;
  padding: 2px 0;
  pointer-events: auto;
  scrollbar-width: none;
}

.chat-timeline-track::-webkit-scrollbar {
  display: none;
}

.chat-timeline-bar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 8px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  outline: none;
  transition: transform 0.15s ease;
}

.chat-timeline-bar {
  display: block;
  width: 16px;
  height: 2.5px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-on-surface-variant);
  opacity: 0.45;
  transition: all 0.2s var(--md-sys-motion-spring-fast);
}

.chat-timeline-bar-btn:hover .chat-timeline-bar {
  width: 24px;
  height: 3px;
  opacity: 1;
  background: var(--md-sys-color-primary);
  box-shadow: 0 0 6px var(--accent-glow);
}

.chat-timeline-bar-btn.active .chat-timeline-bar {
  width: 24px;
  height: 3px;
  opacity: 1;
  background: var(--md-sys-color-primary);
  box-shadow: 0 0 6px var(--accent-glow);
}

/* Popover aperçu d'interaction (M3 Tooltip / Card) */
.chat-timeline-popover {
  position: fixed;
  z-index: 120;
  max-width: 300px;
  padding: 12px 16px;
  border-radius: var(--md-sys-shape-corner-large);
  background: var(--md-sys-color-surface-container-high);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--md-sys-elevation-level3);
  pointer-events: none;
  animation: modalIn 0.15s var(--md-sys-motion-spring-fast);
}

.chat-popover-header {
  font: var(--md-sys-typescale-label-small-emphasized);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 5px;
}

.chat-popover-user {
  font: var(--md-sys-typescale-title-small-emphasized);
  color: var(--md-sys-color-on-surface);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.chat-popover-reply {
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* Surbrillance lors de la navigation par clic sur un point */
.msg.msg-highlight {
  animation: msgHighlight 1.5s ease-out;
}

@keyframes msgHighlight {
  0% {
    box-shadow: 0 0 0 3px var(--accent-glow);
    transform: scale(1.01);
  }
  70% {
    box-shadow: 0 0 0 2px var(--accent-subtle);
  }
  100% {
    box-shadow: none;
    transform: scale(1);
  }
}

/* Alignement et protection de la zone d'ecriture du Chat */
body.chat-drawer-open .shared-composer-wrap {
  left: calc(50% + 146px);
  max-width: min(840px, calc(100% - 292px));
  padding-left: 20px !important;
  padding-right: 20px !important;
  z-index: 45;
  transition: left 0.28s var(--md-sys-motion-spring-default), max-width 0.28s var(--md-sys-motion-spring-default);
}

@media (max-width: 960px) {
  .shared-composer-wrap {
    padding-right: 20px !important;
    padding-left: 20px !important;
  }
}

/* ==========================================================================
   M3 Expressive Conversational Clustering & Suggestion Chips
   ========================================================================== */

/* Message Grouping (Consecutive Shape Clustering) */
.msg.user + .msg.user {
  border-top-right-radius: var(--md-sys-shape-corner-extra-small);
  margin-top: -6px;
}
.msg:not(.user) + .msg:not(.user) {
  border-top-left-radius: var(--md-sys-shape-corner-extra-small);
  margin-top: -6px;
}

/* M3 Expressive Chat Empty State & Suggestion Chips */
.chat-empty-state {
  margin: auto 0;
  padding: 36px 16px 20px;
}
.chat-suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 580px;
  margin-top: 16px;
}
.chat-suggestion-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-label-medium);
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-level1);
  transition: transform var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-fast),
              background-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects),
              border-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects),
              box-shadow var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects);
  user-select: none;
}
.chat-suggestion-chip:hover {
  background: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-outline);
  transform: translateY(-2px);
  box-shadow: var(--md-sys-elevation-level2);
}
.chat-suggestion-chip:active {
  transform: scale(0.96);
}
.chat-suggestion-chip svg {
  color: var(--md-sys-color-primary);
  flex-shrink: 0;
}

/* ==========================================================================
   M3 Expressive Chat Breakpoints & Adaptive Drawer / Controls
   ========================================================================== */

@media (max-width: 599px) {
  /* Tiroir des discussions transforme en Modal Navigation Drawer */
  .chat-sessions-drawer {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100%;
    max-height: 100%;
    margin: 0;
    border-radius: 0 24px 24px 0;
    z-index: 80;
    width: 0;
  }
  .chat-sessions-drawer.revealed,
  .chat-sessions-drawer.pinned-open {
    width: min(300px, 85vw);
    min-width: min(300px, 85vw);
    margin: 0;
    box-shadow: var(--md-sys-elevation-level4);
  }
  .chat-sessions-drawer-header,
  .chat-sessions-list {
    width: 100%;
  }

  /* Bouton d'ouverture en haut a gauche */
  .chat-sessions-toggle-btn {
    left: 12px;
    top: 12px;
    width: 36px;
    height: 36px;
    z-index: 60;
  }
  .chat-sessions-toggle-btn svg {
    width: 18px;
    height: 18px;
  }

  /* Barre d'actions en haut a droite en ligne */
  .chat-right-actions-bar {
    position: absolute;
    top: 12px;
    right: 12px;
    margin: 0;
    height: auto;
    width: auto;
    z-index: 55;
  }
  .chat-right-top-actions {
    flex-direction: row;
    gap: 6px;
  }
  .chat-side-action-btn {
    width: 36px;
    height: 36px;
  }
  .chat-timeline-nav {
    display: none !important;
  }

  /* Flux central degage des boutons superieurs */
  .chat-panel-inner {
    padding-top: 56px !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .msg {
    max-width: 90%;
    font-size: 0.9375rem;
    padding: 10px 14px;
  }
}

