/* ===================================================================
   KineBot — Dark theme, mobile-first
   =================================================================== */

/* --- Reset & base -------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:           #0d1117;
  --surface:      #161b22;
  --surface-2:    #21262d;
  --surface-3:    #2d333b;
  --border:       #30363d;
  --border-hover: #484f58;
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-faint:   #484f58;
  --blue:         #1f6feb;
  --blue-hover:   #388bfd;
  --blue-dim:     #1158b0;
  --green:        #238636;
  --green-hover:  #2ea043;
  --red:          #f85149;
  --red-hover:    #ff7b72;
  --red-dark:     #da3633;
  --header-h:     60px;
  --inputbar-h:   76px;
  --sidebar-w:    320px;
  --radius-sm:    8px;
  --radius-md:    14px;
  --radius-lg:    20px;
  --radius-xl:    24px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.4);
  --shadow-md:    0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.6);
  --font:         'Inter', system-ui, -apple-system, sans-serif;
  --transition:   0.2s ease;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

ul { padding-left: 1.4em; }
li { margin: 2px 0; }
p + p { margin-top: 6px; }
strong { font-weight: 600; color: #fff; }
a { color: var(--blue-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Scrollbars */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* --- Header -------------------------------------------------------- */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

#header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#header-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s;
}
#header-logo:hover {
  background: var(--surface-3);
}

#header-title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
  white-space: nowrap;
  cursor: pointer;
}
#header-title:hover {
  color: var(--accent, #4a9eff);
}

#header-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  display: none;
}

@media (min-width: 480px) {
  #header-subtitle { display: block; }
}

#header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#patients-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

#patients-toggle:hover {
  background: var(--surface-3);
  border-color: var(--border-hover);
  color: #fff;
}

#patients-toggle.active {
  background: var(--blue-dim);
  border-color: var(--blue);
  color: #fff;
}

/* --- Main / chat area ---------------------------------------------- */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-top: var(--header-h);
  margin-bottom: var(--inputbar-h);
  position: relative;
  overflow: hidden;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scroll-behavior: smooth;
}

/* --- Message bubbles ----------------------------------------------- */
.message {
  display: flex;
  padding: 2px 16px;
  animation: msgFadeIn 0.2s ease both;
}

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message-inner {
  max-width: min(80%, 640px);
  display: flex;
  flex-direction: column;
}

.message.user {
  justify-content: flex-end;
}

.message.bot {
  justify-content: flex-start;
}

.message-content {
  padding: 11px 15px;
  border-radius: var(--radius-lg);
  font-size: 14.5px;
  line-height: 1.65;
  word-break: break-word;
}

.message.user .message-content {
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.bot .message-content {
  background: var(--surface-2);
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}

.message.error .message-content {
  background: rgba(248, 81, 73, 0.12);
  border-color: rgba(248, 81, 73, 0.4);
  color: var(--red-hover);
}

/* Message timestamp */
.message-meta {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 3px;
  padding: 0 4px;
}

.message.user .message-meta { text-align: right; }

/* --- Action buttons ------------------------------------------------ */
.actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 100px;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: filter var(--transition), transform var(--transition);
  white-space: nowrap;
}

.action-btn:active { transform: scale(0.96); }
.action-btn:hover  { filter: brightness(1.15); }

.action-btn.confirm { background: var(--green);    color: #fff; }
.action-btn.cancel  { background: var(--red-dark); color: #fff; }
.action-btn.info    { background: var(--blue);     color: #fff; }
.action-btn.neutral {
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
}

/* --- Chart images -------------------------------------------------- */
.chart-img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 8px 0;
  border: 1px solid var(--border);
  display: block;
}

/* --- Patient cards ------------------------------------------------- */
.patient-card {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 8px 0 0;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.patient-card:hover {
  border-color: var(--blue);
  background: rgba(31, 111, 235, 0.06);
}

.patient-card-name {
  font-weight: 600;
  color: #fff;
  font-size: 15px;
}

.patient-card-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* History table inside patient card */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-top: 10px;
}

.history-table th,
.history-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.history-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-table tr:last-child td { border-bottom: none; }
.history-table tbody tr:hover td { background: rgba(255,255,255,.03); }

.edit-exercise-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
  transition: all .15s;
}
.edit-exercise-btn:hover {
  color: var(--blue-hover);
  border-color: var(--blue);
  background: rgba(31,111,235,.1);
}
.del-exercise-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
  transition: all .15s;
}
.del-exercise-btn:hover {
  color: var(--red-hover);
  border-color: var(--red);
  background: rgba(248,81,73,.1);
}

/* --- Typing indicator ---------------------------------------------- */
#typing-indicator {
  padding: 4px 16px 8px;
  display: flex;
}

#typing-indicator[hidden] { display: none; }

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
  padding: 10px 14px;
  max-width: 180px;
}

.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingDot 1.4s ease-in-out infinite;
  flex-shrink: 0;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
  40%           { opacity: 1;    transform: scale(1.15); }
}

.typing-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* --- Input bar ----------------------------------------------------- */
#input-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 150;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 8px 12px env(safe-area-inset-bottom, 8px);
}

#recording-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  font-size: 12.5px;
  color: var(--red);
  font-weight: 500;
}

#recording-indicator[hidden] { display: none; }

#rec-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--red);
  animation: recPulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes recPulse {
  0%, 100% { opacity: 1;   transform: scale(1);   box-shadow: 0 0 0 0 rgba(248,81,73,.5); }
  50%       { opacity: 0.8; transform: scale(1.15); box-shadow: 0 0 0 5px rgba(248,81,73,0); }
}

#input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

#input-wrap {
  flex: 1;
  position: relative;
}

#text-input {
  width: 100%;
  min-height: 44px;
  max-height: 140px;
  padding: 11px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  resize: none;
  outline: none;
  overflow-y: auto;
  transition: border-color var(--transition), background var(--transition);
  display: block;
}

#text-input::placeholder { color: var(--text-faint); }

#text-input:focus {
  border-color: var(--border-hover);
  background: var(--surface-3);
}

/* Icon buttons */
#mic-btn, #send-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

#mic-btn {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

#mic-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-hover);
}

#mic-btn.recording {
  background: rgba(248, 81, 73, 0.15);
  color: var(--red);
  border-color: var(--red);
  animation: micPulse 1.4s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,81,73,.35); }
  50%       { box-shadow: 0 0 0 8px rgba(248,81,73,0); }
}

#send-btn {
  background: var(--blue);
  color: #fff;
}

#send-btn:hover:not(:disabled) {
  background: var(--blue-hover);
  transform: scale(1.06);
}

#send-btn:disabled {
  background: var(--surface-3);
  color: var(--text-faint);
  cursor: not-allowed;
}

#input-hint {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  margin-top: 5px;
  display: none;
}

@media (min-width: 600px) {
  #input-hint { display: block; }
}

/* --- Patients sidebar ---------------------------------------------- */
#patients-sidebar {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: var(--sidebar-w);
  max-width: 100vw;
  z-index: 300;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

#patients-sidebar.open {
  transform: translateX(0);
  box-shadow: var(--shadow-lg);
}

#sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 299;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

#sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

#sidebar-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}

#sidebar-close:hover {
  background: var(--surface-3);
  color: var(--text);
}

#sidebar-search-wrap {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#sidebar-search {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--transition);
}

#sidebar-search::placeholder { color: var(--text-faint); }
#sidebar-search:focus { border-color: var(--border-hover); }

#patients-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 32px 0;
}

.loading-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: typingDot 1.2s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

.sidebar-patient-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}

.sidebar-patient-item:hover {
  background: var(--surface-2);
}

.sidebar-patient-item:last-child {
  border-bottom: none;
}

.sidebar-add-btn {
  width: 100%;
  padding: 10px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  color: var(--blue-hover);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 8px;
  transition: all .15s;
}
.sidebar-add-btn:hover {
  background: var(--surface-3);
  border-color: var(--blue);
}

.patient-item-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity .15s;
}
.sidebar-patient-item:hover .patient-item-actions {
  opacity: 1;
}
.patient-act-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1;
  transition: all .15s;
}
.patient-act-btn:hover { color: var(--blue-hover); border-color: var(--blue); }
.patient-del:hover { color: var(--red-hover); border-color: var(--red); }

.patient-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-dim), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.patient-info { flex: 1; min-width: 0; }

.patient-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.patient-seances {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.patient-arrow {
  color: var(--text-faint);
  flex-shrink: 0;
}

.sidebar-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.sidebar-empty svg {
  margin-bottom: 12px;
  opacity: 0.4;
}

/* --- Desktop layout (sidebar always visible) ----------------------- */
@media (min-width: 900px) {
  #patients-sidebar {
    transform: translateX(0);
    box-shadow: none;
  }

  #patients-sidebar:not(.open) {
    transform: translateX(100%);
  }

  #sidebar-overlay { display: none; }
}

/* Desktop: sidebar overlays content (no shift) */

/* Mobile: sidebar covers full screen below 400px */
@media (max-width: 400px) {
  #patients-sidebar { width: 100%; }
}

/* --- Patient Dashboard ----------------------------------------------- */
.patient-dashboard {
  max-width: 100% !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
}

.dash-header {
  padding: 16px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
}

.dash-name {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.dash-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.dash-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.metric-card {
  padding: 14px 12px;
  text-align: center;
  background: var(--surface);
}

.metric-value {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.dash-section {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-top: none;
  background: var(--surface);
}

.dash-section:last-child {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.dash-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 8px;
}

.dash-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dash-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
}

.dash-tag small {
  color: var(--text-muted);
  font-size: 11px;
}

.dash-tag.bilan-link {
  color: var(--blue-hover);
  text-decoration: none;
  cursor: pointer;
  transition: border-color var(--transition);
}

.dash-tag.bilan-link:hover {
  border-color: var(--blue);
}

.patient-dashboard .history-table {
  margin-top: 0;
}

.patient-dashboard .history-table td strong {
  color: var(--blue-hover);
}

/* ===================================================================
   Sprint 1 — New feature styles
   =================================================================== */

/* --- A) Readiness score gauge -------------------------------------- */
.readiness-score {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
}

.readiness-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  position: relative;
  transition: border-color var(--transition), background var(--transition);
}

/* Color variants via data-color attribute */
.readiness-score[data-color="green"] .readiness-circle {
  border-color: #3fb950;
  background: rgba(63, 185, 80, 0.10);
}

.readiness-score[data-color="yellow"] .readiness-circle {
  border-color: #d29922;
  background: rgba(210, 153, 34, 0.10);
}

.readiness-score[data-color="red"] .readiness-circle {
  border-color: #f85149;
  background: rgba(248, 81, 73, 0.10);
}

.readiness-value {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  letter-spacing: -1px;
}

.readiness-score[data-color="green"] .readiness-value { color: #3fb950; }
.readiness-score[data-color="yellow"] .readiness-value { color: #d29922; }
.readiness-score[data-color="red"] .readiness-value    { color: #f85149; }

.readiness-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.readiness-components {
  list-style: none;
  padding: 0;
  margin: 2px 0 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  font-size: 11.5px;
  color: var(--text-muted);
  min-width: 120px;
}

.readiness-components li {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
}

.readiness-components li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

/* --- B) Personal Record alert -------------------------------------- */
@keyframes prPulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.pr-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border-left: 4px solid #d29922;
  background: linear-gradient(90deg, rgba(210, 153, 34, 0.15) 0%, rgba(210, 153, 34, 0.02) 100%);
  margin: 8px 0;
  animation: prPulse 0.5s ease-out both;
}

.pr-icon {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}

.pr-alert-body {
  flex: 1;
  min-width: 0;
}

.pr-alert-title {
  font-weight: 700;
  color: #d29922;
  font-size: 14px;
}

.pr-alert-desc {
  font-size: 13px;
  color: var(--text);
  margin-top: 2px;
}

/* --- C) Red flag alert --------------------------------------------- */
@keyframes redFlagBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

.red-flag-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border-left: 4px solid #f85149;
  background: rgba(248, 81, 73, 0.10);
  margin: 8px 0;
}

.red-flag-icon {
  font-size: 20px;
  line-height: 1.2;
  flex-shrink: 0;
  animation: redFlagBlink 1s ease-in-out infinite;
}

.red-flag-body {
  flex: 1;
  min-width: 0;
}

.red-flag-title {
  font-weight: 600;
  color: #f85149;
  font-size: 13.5px;
}

.red-flag-action {
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 3px;
  line-height: 1.5;
}

/* --- D) RGPD local badge ------------------------------------------- */
.badge-local {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: #3fb950;
  background: rgba(63, 185, 80, 0.12);
  border: 1px solid rgba(63, 185, 80, 0.30);
  border-radius: 100px;
  white-space: nowrap;
  vertical-align: middle;
}

/* --- Mute button --------------------------------------------------- */
#mute-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  flex-shrink: 0;
}
#mute-btn:hover {
  background: var(--surface-3);
  border-color: var(--border-hover);
  color: #fff;
}
#mute-btn.muted {
  color: var(--red);
  border-color: rgba(248, 81, 73, 0.4);
  background: rgba(248, 81, 73, 0.08);
}

/* --- E) Chart controls --------------------------------------------- */
.chart-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
}

.chart-period-btn {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}

.chart-period-btn:hover {
  background: var(--surface-3);
  border-color: var(--border-hover);
  color: var(--text);
}

.chart-period-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.chart-selector {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}

.chart-selector:hover,
.chart-selector:focus {
  border-color: var(--border-hover);
}

.chart-fullscreen-btn {
  margin-left: auto;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.chart-fullscreen-btn:hover {
  background: var(--surface-3);
  border-color: var(--border-hover);
  color: var(--text);
}

/* --- F) Chart fullscreen modal ------------------------------------- */
.chart-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.80);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: modalFadeIn 0.18s ease both;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.chart-modal[hidden] {
  display: none;
}

.chart-modal-inner {
  position: relative;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-modal-img {
  max-width: 95vw;
  max-height: 90vh;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  object-fit: contain;
  box-shadow: var(--shadow-lg);
}

.chart-modal-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  box-shadow: var(--shadow-sm);
}

.chart-modal-close:hover {
  background: var(--surface-3);
  color: var(--text);
}

/* --- G) Check-in button -------------------------------------------- */
.checkin-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(63, 185, 80, 0.40);
  background: rgba(63, 185, 80, 0.10);
  color: #3fb950;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}

.checkin-btn:hover {
  background: rgba(63, 185, 80, 0.20);
  border-color: #3fb950;
  color: #52d068;
}

.checkin-btn:active {
  transform: scale(0.96);
}

/* --- H) Export PDF button ------------------------------------------ */
.export-pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: #1a4e8c;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .1s;
}

.export-pdf-btn:hover {
  background: #2563ab;
}

.export-pdf-btn:active {
  transform: scale(0.96);
}

/* ===================================================================
   Sprint 4.1 — Mannequin anatomique
   =================================================================== */

/* --- Wrapper & sizing ---------------------------------------------- */
.mannequin-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 4px 0 2px;
  user-select: none;
}

.mannequin-svg {
  width: 100%;
  max-width: 300px;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
  /* subtle inner glow to distinguish from chat bubble bg */
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.45));
}

@media (min-width: 480px) {
  .mannequin-svg { max-width: 340px; }
}

/* --- Muscle zone paths --------------------------------------------- */
.mq-zone {
  cursor: pointer;
  transition: filter 0.15s ease, stroke-width 0.1s ease;
  /* Smooth fill transitions when data updates */
  /* (fill transitions not well supported in SVG — handled via JS classes) */
}

.mq-zone:focus-visible {
  outline: 2px solid var(--blue-hover);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Tooltip ------------------------------------------------------- */
.mannequin-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  padding: 8px 12px;
  background: var(--surface-3);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  box-shadow: var(--shadow-md);
  max-width: 200px;
  white-space: normal;
  /* Hidden by default */
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.mannequin-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.mannequin-tooltip strong {
  color: #fff;
  display: block;
  margin-bottom: 2px;
}

.tt-pain {
  color: var(--red-hover);
  font-weight: 600;
}

.tt-idle {
  color: var(--text-muted);
  font-style: italic;
}

/* --- Legend -------------------------------------------------------- */
.mannequin-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
}

.ml-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ml-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.ml-green { background: rgba(35,134,54,0.65);  border: 1px solid #3fb950; }
.ml-blue  { background: rgba(31,111,235,0.50); border: 1px solid #388bfd; }
.ml-gray  { background: rgba(48,54,61,0.80);   border: 1px solid #6e7681; }
.ml-red   { background: rgba(248,81,73,0.45);  border: 1px solid #f85149; }

/* --- Chat message container ---------------------------------------- */
.mannequin-message {
  /* Wider than default bot bubble — mannequin needs room */
  padding: 12px 14px;
}

.mannequin-caption {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mannequin-container {
  /* Let the SVG breathe horizontally */
  display: flex;
  justify-content: center;
}

/* Mobile: ensure mannequin message bubble is wide enough */
@media (max-width: 480px) {
  .message.bot .message-inner:has(.mannequin-message) {
    max-width: 95%;
  }
}

/* --- H) Mobile responsive tables ----------------------------------- */
@media (max-width: 600px) {
  /* Exercise history: card layout on mobile */
  .dash-section .history-table thead { display: none; }
  .dash-section .history-table,
  .dash-section .history-table tbody {
    display: block;
    width: 100%;
  }
  .dash-section .history-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }
  .dash-section .history-table tr:last-child { border-bottom: none; }
  .dash-section .history-table td {
    display: inline;
    padding: 0;
    border-bottom: none;
    font-size: 12.5px;
    white-space: nowrap;
  }
  /* Row 1: date + exercise name (full width) */
  .dash-section .history-table td:nth-child(1) {
    color: var(--text-muted);
    font-size: 11px;
    order: 1;
  }
  .dash-section .history-table td:nth-child(2) {
    flex-basis: 100%;
    white-space: normal;
    font-weight: 600;
    order: 2;
  }
  /* Row 2: metrics inline */
  .dash-section .history-table td:nth-child(3) { order: 3; }  /* Reps */
  .dash-section .history-table td:nth-child(4) { order: 4; }  /* Kg */
  .dash-section .history-table td:nth-child(5) { order: 5; }  /* Séries */
  .dash-section .history-table td:nth-child(6) { order: 6; }  /* Tonnage */
  /* Actions */
  .dash-section .history-table td:nth-child(7) {
    order: 7;
    margin-left: auto;
  }
  /* Add labels on mobile */
  .dash-section .history-table td:nth-child(3)::before { content: "Reps: "; color: var(--text-muted); }
  .dash-section .history-table td:nth-child(4)::before { content: "Charge: "; color: var(--text-muted); }
  .dash-section .history-table td:nth-child(5)::before { content: "Séries: "; color: var(--text-muted); }
  .dash-section .history-table td:nth-child(6)::before { content: "Vol: "; color: var(--text-muted); }

  /* Clinical tests table: also card layout */
  .dash-section .history-table .test-interp {
    white-space: normal;
    font-size: 11.5px;
    color: var(--text-muted);
  }

  /* Metrics grid: 2 cols on narrow screens */
  .dash-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  .dash-metrics .metric-card:last-child {
    grid-column: span 2;
  }

  /* Message bubbles: wider on mobile */
  .message-inner { max-width: 95%; }

  /* Charts: full width */
  .chart-img { max-width: 100%; }
}

/* ===================================================================
   Sprint 5 — New feature styles
   =================================================================== */

/* -------------------------------------------------------------------
   Feature 1 — Calendar Heatmap
   ------------------------------------------------------------------- */

.calendar-heatmap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-x: auto;
  padding: 4px 0 2px;
  -webkit-overflow-scrolling: touch;
}

/* Month label row: free-flow, not a grid */
.cal-months {
  display: flex;
  padding-left: 0;
  min-height: 14px;
  position: relative;
  margin-bottom: 2px;
}

.cal-month-label {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.3px;
  margin-right: 6px;
  flex-shrink: 0;
}

/* Grid: row of weekly columns */
.cal-grid {
  display: flex;
  gap: 2px;
  align-items: flex-start;
}

/* Each column = one week = 7 stacked day cells */
.cal-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Individual day cell */
.cal-day {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--surface-3);
  border: 1px solid rgba(48, 54, 61, 0.6);
  flex-shrink: 0;
  transition: filter 0.1s ease;
  cursor: default;
}

.cal-day:hover {
  filter: brightness(1.4);
  outline: 1px solid var(--border-hover);
  outline-offset: 1px;
}

/* Active day — 4 green intensity levels */
.cal-day-active {
  border-color: transparent;
}

.cal-day-l1 {
  background: rgba(35, 134, 54, 0.25);
  border-color: rgba(35, 134, 54, 0.35);
}

.cal-day-l2 {
  background: rgba(35, 134, 54, 0.45);
  border-color: rgba(35, 134, 54, 0.55);
}

.cal-day-l3 {
  background: rgba(35, 134, 54, 0.65);
  border-color: rgba(63, 185, 80, 0.55);
}

.cal-day-l4 {
  background: rgba(35, 134, 54, 0.88);
  border-color: #3fb950;
}

/* Future dates: very faint */
.cal-day-future {
  background: rgba(48, 54, 61, 0.20);
  border-color: rgba(48, 54, 61, 0.3);
}

/* Legend row */
.cal-legend {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
  justify-content: flex-end;
}

.cal-legend-label {
  font-size: 10px;
  color: var(--text-faint);
  white-space: nowrap;
}

.cal-legend-swatch {
  cursor: default !important;
}

@media (max-width: 480px) {
  .cal-day { width: 8px; height: 8px; }
  .cal-grid { gap: 1px; }
  .cal-col  { gap: 1px; }
}

/* -------------------------------------------------------------------
   Feature 2 — Timeline Display
   ------------------------------------------------------------------- */

.timeline-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 4px 0;
}

.timeline-item {
  display: grid;
  grid-template-columns: 14px 1fr;
  grid-template-rows: auto;
  column-gap: 12px;
  position: relative;
  padding-bottom: 16px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

/* Vertical connecting line (occupies dot column, full row height) */
.timeline-line {
  grid-column: 1;
  grid-row: 1 / 3;
  width: 2px;
  background: var(--border);
  margin: 14px auto 0;
  min-height: 100%;
  border-radius: 1px;
  position: absolute;
  left: 6px;
  top: 14px;
  bottom: -2px;
}

/* Colored dot */
.timeline-dot {
  grid-column: 1;
  grid-row: 1;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface-3);
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
  z-index: 1;
}

/* Dot colors by event type */
.timeline-dot-seance   { background: rgba(35,134,54,0.35);  border-color: #3fb950; }
.timeline-dot-bilan    { background: rgba(31,111,235,0.35); border-color: #388bfd; }
.timeline-dot-test     { background: rgba(130,80,220,0.35); border-color: #a371f7; }
.timeline-dot-milestone {
  background: rgba(210,153,34,0.40);
  border-color: #d29922;
  box-shadow: 0 0 0 3px rgba(210,153,34,0.15);
}

/* Content area */
.timeline-content {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.timeline-date {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.timeline-label {
  font-size: 13.5px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
}

.timeline-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

/* -------------------------------------------------------------------
   Feature 3 — Ambient Mode Button
   ------------------------------------------------------------------- */

.ambient-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), box-shadow var(--transition);
  overflow: visible;
}

.ambient-btn:hover {
  background: var(--surface-3);
  border-color: var(--border-hover);
  color: var(--text);
}

/* Active (consultation open) state — red */
.ambient-btn.active {
  background: rgba(35, 134, 54, 0.15);
  border-color: #3fb950;
  color: #3fb950;
  animation: ambientGlow 2s ease-in-out infinite;
}

@keyframes ambientGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.4); }
  50%       { box-shadow: 0 0 0 8px rgba(63, 185, 80, 0); }
}

/* Microphone-wave pulse rings when active */
.ambient-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}

.ambient-pulse::before,
.ambient-pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(63, 185, 80, 0.5);
  animation: ambientRipple 2s ease-out infinite;
}

.ambient-pulse::after {
  animation-delay: 1s;
}

@keyframes ambientRipple {
  0%   { transform: scale(1);    opacity: 0.7; }
  100% { transform: scale(1.9);  opacity: 0; }
}

/* -------------------------------------------------------------------
   Feature 4 — Body Map (renderBodyMap)
   ------------------------------------------------------------------- */

.body-map-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  user-select: none;
}

.body-map-svg {
  width: 100%;
  max-width: 220px;
  height: auto;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.45));
}

@media (min-width: 480px) {
  .body-map-svg { max-width: 260px; }
}

/* Interactive muscle region paths */
.muscle-region {
  cursor: pointer;
  transition: filter 0.15s ease;
}

.muscle-region:focus-visible {
  outline: 2px solid var(--blue-hover);
  outline-offset: 2px;
}

/* Gradient bar legend */
.body-map-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.body-map-gradient-bar {
  width: 80px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(
    to right,
    rgba(35, 134, 54, 0.20),
    rgba(35, 134, 54, 0.88)
  );
  border: 1px solid rgba(63, 185, 80, 0.3);
}

.body-map-legend-label {
  font-size: 10px;
  color: var(--text-faint);
  white-space: nowrap;
}

/* -------------------------------------------------------------------
   TTS Play Button
   ------------------------------------------------------------------- */

.tts-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.tts-btn:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--surface-3);
}

.tts-btn.tts-loading {
  opacity: 0.5;
  cursor: wait;
}

.tts-btn.tts-playing {
  color: #3fb950;
  border-color: #3fb950;
  background: rgba(35, 134, 54, 0.10);
}

/* -------------------------------------------------------------------
   Mannequin body map (mannequin.js)
   ------------------------------------------------------------------- */

.mannequin-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  user-select: none;
}

.mannequin-svg {
  width: 100%;
  max-width: 240px;
  height: auto;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.45));
}

@media (min-width: 480px) {
  .mannequin-svg { max-width: 280px; }
}

.mq-zone {
  cursor: pointer;
  transition: filter 0.15s ease;
}

.mq-zone:focus-visible {
  outline: 2px solid var(--blue-hover);
  outline-offset: 2px;
}

.mannequin-tooltip {
  position: fixed;
  z-index: 10000;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  max-width: 200px;
}

.mannequin-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.mannequin-tooltip .tt-pain { color: #f85149; font-weight: 600; }
.mannequin-tooltip .tt-idle { color: var(--text-faint); }

.mannequin-caption {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mannequin-message {
  padding: 12px 14px;
}

.mannequin-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.ml-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.ml-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid transparent;
}

.ml-green { background: rgba(35,134,54,0.35); border-color: #3fb950; }
.ml-blue  { background: rgba(31,111,235,0.28); border-color: #388bfd; }
.ml-gray  { background: rgba(48,54,61,0.40); border-color: #6e7681; }
.ml-red   { background: rgba(248,81,73,0.30); border-color: #f85149; }

/* ===================================================================
   UX Mobile — Collapsibles, Tables, Pills, Borders, Sticky, Jump FAB
   =================================================================== */

/* --- Collapsible messages ------------------------------------------ */
.msg-collapsible > summary {
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  border-radius: var(--radius-md);
  transition: background 0.15s;
}
.msg-collapsible > summary::-webkit-details-marker { display: none; }
.msg-collapsible > summary::before {
  content: '\25B6';
  font-size: 0.65em;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.msg-collapsible[open] > summary::before {
  transform: rotate(90deg);
}
.msg-collapsible > summary:hover {
  background: var(--surface-3);
}
.msg-collapsible .collapsible-body {
  padding: 8px 14px 12px;
}

/* --- Responsive clinical tables → cards on mobile ------------------ */
.clinical-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 8px 0;
}
.clinical-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.clinical-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--surface-3);
}
@media (max-width: 600px) {
  .clinical-table thead { display: none; }
  .clinical-table tr {
    display: block;
    margin-bottom: 10px;
    background: var(--surface-2);
    border-radius: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
  }
  .clinical-table td {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid var(--surface-3);
  }
  .clinical-table td:last-child { border-bottom: none; }
  .clinical-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 12px;
    font-size: 12px;
  }
}

/* --- Metric pills -------------------------------------------------- */
.metric-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.metric-pill .label { color: var(--text-muted); font-size: 12px; }
.metric-pill .value { color: #e0e0ec; font-weight: 600; }
.metric-pill .value.good { color: #3fb950; }
.metric-pill .value.warning { color: #d29922; }
.metric-pill .value.alert { color: #f85149; }
.metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}

/* --- Message type borders ------------------------------------------ */
.message[data-type="exercise"] .message-content  { border-left: 3px solid #238636; }
.message[data-type="test"] .message-content       { border-left: 3px solid #388bfd; }
.message[data-type="alert"] .message-content       { border-left: 3px solid #f85149; }
.message[data-type="bilan"] .message-content       { border-left: 3px solid #a371f7; }
.message[data-type="protocol"] .message-content    { border-left: 3px solid #d29922; }

/* --- Sticky session header ----------------------------------------- */
.session-sticky-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: none;
}
.session-sticky-header.visible { display: flex; align-items: center; gap: 12px; }
.session-sticky-header .patient-name { font-weight: 600; color: var(--text); }

/* --- Jump-to-bottom FAB -------------------------------------------- */
#jump-bottom {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 15;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: var(--shadow-md);
}
#jump-bottom.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
#jump-bottom:hover {
  background: var(--surface-3);
  border-color: var(--border-hover);
}

/* --- Container queries --------------------------------------------- */
#chat-messages { container-type: inline-size; }
@container (max-width: 400px) {
  .metric-row { gap: 4px; }
  .metric-pill { font-size: 12px; padding: 2px 8px; }
  .msg-collapsible > summary { font-size: 12.5px; padding: 8px 10px; }
}

/* --- Assessment path menu ------------------------------------------ */
.assessment-menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}
@media (max-width: 400px) {
  .assessment-menu { grid-template-columns: 1fr; }
}
.assessment-menu .action-btn {
  padding: 12px 10px;
  text-align: center;
  font-size: 13px;
}

/* --- Goniometry / MMT step tables ---------------------------------- */
.gonio-input-row, .mmt-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--surface-3);
}
.gonio-input-row .movement-label, .mmt-input-row .muscle-label {
  flex: 1;
  font-weight: 500;
  font-size: 13px;
}
.gonio-input-row .norm {
  font-size: 11px;
  color: var(--text-muted);
}
