@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600;8..60,700&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ---------- Thème : couleurs ---------- */

:root {
  --bg: #f3f5f4;
  --rail-bg: #eaedec;
  --surface: #ffffff;
  --surface-2: #f7f8f8;
  --border: #dde1e0;
  --border-strong: #c7cdcb;
  --text: #121a1a;
  --text-muted: #5b6866;
  --text-faint: #8b9694;

  --accent: #0f6e6a;
  --accent-hover: #0b5652;
  --accent-soft: #e3f1ef;
  --accent-contrast: #ffffff;

  --signal: #d98c2b;
  --signal-soft: #fbeed9;
  --signal-strong: #b56f1c;

  --danger: #c4453c;
  --danger-bg: #fbeae8;
  --success: #1f8a5f;
  --success-bg: #e6f5ee;

  --timing-c1: #2a78d6;
  --timing-c2: #eb6834;
  --timing-c3: #1baf7a;
  --timing-c4: #eda100;

  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-float: 0 12px 28px rgba(15, 26, 25, 0.14);

  --font-display: 'Source Serif 4', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', "SFMono-Regular", Consolas, monospace;

  /* Largeur des conteneurs `.page` / `nav.topnav` : une proportion de la
     fenêtre plutôt qu'un plafond fixe en pixels, pour exploiter l'espace
     disponible sur les grands écrans. En dessous de 900px (mobile/tablette,
     déjà en une seule colonne via `.workspace`), on garde 100% : réduire la
     largeur n'y apporterait rien. Au-delà, 90% jusqu'à 1600px, puis 80% sur
     les très grands écrans où cette proportion représente déjà beaucoup de
     pixels. */
  --page-width: 100%;

  color-scheme: light;
}

@media (min-width: 900px) {
  :root { --page-width: 90%; }
}

@media (min-width: 1600px) {
  :root { --page-width: 80%; }
}

:root[data-theme="dark"] {
  --bg: #0e1514;
  --rail-bg: #101918;
  --surface: #16201f;
  --surface-2: #1c2726;
  --border: #263332;
  --border-strong: #34423f;
  --text: #e9efed;
  --text-muted: #9fada9;
  --text-faint: #6f7c79;

  --accent: #35c9c1;
  --accent-hover: #55d8d1;
  --accent-soft: #12302d;
  --accent-contrast: #04211f;

  --signal: #f0b860;
  --signal-soft: #322415;
  --signal-strong: #f6c877;

  --danger: #f0847b;
  --danger-bg: #3a1e1c;
  --success: #5fd8a4;
  --success-bg: #123326;

  --timing-c1: #3987e5;
  --timing-c2: #d95926;
  --timing-c3: #199e70;
  --timing-c4: #c98500;

  --shadow-float: 0 12px 32px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1514;
    --rail-bg: #101918;
    --surface: #16201f;
    --surface-2: #1c2726;
    --border: #263332;
    --border-strong: #34423f;
    --text: #e9efed;
    --text-muted: #9fada9;
    --text-faint: #6f7c79;

    --accent: #35c9c1;
    --accent-hover: #55d8d1;
    --accent-soft: #12302d;
    --accent-contrast: #04211f;

    --signal: #f0b860;
    --signal-soft: #322415;
    --signal-strong: #f6c877;

    --danger: #f0847b;
    --danger-bg: #3a1e1c;
    --success: #5fd8a4;
    --success-bg: #123326;

    --timing-c1: #3987e5;
    --timing-c2: #d95926;
    --timing-c3: #199e70;
    --timing-c4: #c98500;

    --shadow-float: 0 12px 32px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.page {
  width: var(--page-width);
  margin: 0 auto;
  padding: 20px 24px 64px;
}

.auth-page { max-width: 420px; }

/* ---------- Navigation ---------- */

nav.topnav {
  display: flex;
  gap: 4px;
  align-items: center;
  width: var(--page-width);
  margin: 0 auto;
  padding: 18px 24px 0;
}

nav.topnav .brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  margin-right: 20px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

nav.topnav .brand::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}

nav.topnav a {
  text-decoration: none;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
}

nav.topnav a:hover { color: var(--text); }

nav.topnav a.active {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

nav.topnav .nav-spacer { margin-left: auto; }

.nav-user {
  font-size: 13px;
  color: var(--text-muted);
  margin-right: 4px;
  font-family: var(--font-mono);
}

.btn-nav { padding: 7px 12px; font-size: 13px; }

/* Interrupteur clair / sombre */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 13px;
  margin-right: 6px;
}

.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }

.theme-toggle svg { width: 15px; height: 15px; display: block; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ---------- Titres de page ---------- */

h1 {
  font-size: 26px;
  margin: 20px 0 4px;
}

p.subtitle {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 14.5px;
  max-width: 62ch;
}

/* ---------- Mise en page "atelier" : rail + document ---------- */

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.rail {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.main-pane {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .rail { position: static; }
}

/* ---------- Cartes ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.rail .card { background: var(--rail-bg); }

.card-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 14px;
}

/* ---------- Zone de dépôt ---------- */

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface);
}

.rail .dropzone { background: var(--surface-2); }

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone p { margin: 4px 0; font-size: 14px; }
.dropzone .hint { color: var(--text-muted); font-size: 12.5px; }

.file-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  font-size: 13.5px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  word-break: break-all;
}

.file-info button {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
  margin-left: 10px;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.badge-live {
  background: var(--signal-soft);
  border-color: transparent;
  color: var(--signal-strong);
}

.badge-live::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.badge-available {
  background: var(--signal-soft);
  border-color: transparent;
  color: var(--signal-strong);
}

.badge-soon {
  background: transparent;
  border-style: dashed;
}

/* ---------- Page Outils ---------- */

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.tool-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease;
}

.tool-card:hover { border-color: var(--accent); }

.tool-card .card-title { flex-wrap: wrap; }

.tool-card-soon {
  cursor: default;
  opacity: 0.65;
  border-style: dashed;
}

.tool-card-soon:hover { border-color: var(--border); }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-signal {
  background: var(--signal);
  color: #241a08;
}
.btn-signal:hover:not(:disabled) { background: var(--signal-strong); }
.btn-signal:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-block { width: 100%; justify-content: center; }

.btn-full-width { width: 100%; }

.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Alertes ---------- */

.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-info { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }

/* ---------- État vide de l'atelier ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 64px 32px;
  border-style: dashed;
  border-color: var(--border-strong);
  color: var(--text-muted);
}

.empty-state-icon {
  width: 44px;
  height: 44px;
  color: var(--border-strong);
  margin-bottom: 10px;
}

.empty-state .card-title { color: var(--text); }
.empty-state .card-hint { max-width: 42ch; margin: 0; }

/* ---------- Transcription ---------- */

textarea.transcript {
  width: 100%;
  min-height: 380px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  resize: vertical;
}

textarea.instruction-input {
  width: 100%;
  min-height: 104px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.5;
  resize: vertical;
}

/* ---------- Formulaires ---------- */

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

input[type="text"], input[type="password"], input[type="url"], input[type="number"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  margin-bottom: 16px;
}

input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: -10px 0 16px;
}

.provider-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 480px) {
  .provider-choice { grid-template-columns: 1fr; }
}

.provider-option {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  background: var(--surface-2);
}

.provider-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.provider-option strong { display: block; margin-bottom: 4px; font-size: 14px; }
.provider-option span { font-size: 12px; color: var(--text-muted); }

/* ---------- Progression ---------- */

.progress-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin: 10px 0 0;
}

.progress-fill.indeterminate {
  width: 35% !important;
  animation: indeterminate 1.1s ease-in-out infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(385%); }
}

/* ---------- Répartition du temps ---------- */

.timing-chart { display: flex; flex-direction: column; gap: 12px; }

.timing-row { display: flex; align-items: center; gap: 10px; }

.timing-label {
  flex: 0 0 140px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.timing-track {
  flex: 1 1 auto;
  height: 10px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.timing-fill {
  height: 100%;
  min-width: 3px;
  border-radius: 999px;
  background: var(--accent);
}

.timing-row.timing-total .timing-fill { background: var(--text-muted); }

.timing-value {
  flex: 0 0 46px;
  text-align: right;
  font-size: 12.5px;
  font-family: var(--font-mono);
  color: var(--text);
}

@media (max-width: 480px) {
  .timing-label { flex-basis: 96px; font-size: 11.5px; }
  .timing-value { flex-basis: 40px; }
}

.timing-summary { margin-top: 14px; }

.timing-summary-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}

.timing-summary-total {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.timing-bar {
  display: flex;
  gap: 2px;
  height: 22px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--border);
  cursor: pointer;
  border: none;
  width: 100%;
  padding: 0;
}

.timing-bar:hover .timing-segment { filter: brightness(1.08); }

.timing-bar:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.timing-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 6px;
  overflow: hidden;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: #ffffff;
  white-space: nowrap;
}

.timing-segment span { padding: 0 5px; }

.timing-segment[data-stage="0"] { background: var(--timing-c1); }
.timing-segment[data-stage="1"] { background: var(--timing-c2); }
.timing-segment[data-stage="2"] { background: var(--timing-c3); }
.timing-segment[data-stage="3"] { background: var(--timing-c4); }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 13, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-float);
  padding: 20px;
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}

.modal-close:hover { color: var(--text); }

/* ---------- Markdown ---------- */

.markdown-box {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 18px 20px;
  min-height: 60px;
  overflow-x: auto;
}

.markdown-body { font-size: 14.5px; line-height: 1.65; color: var(--text); }
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  font-family: var(--font-display);
  margin: 18px 0 8px;
  line-height: 1.3;
  font-weight: 600;
}
.markdown-body h1 { font-size: 21px; }
.markdown-body h2 { font-size: 18px; }
.markdown-body h3 { font-size: 16px; }
.markdown-body h4, .markdown-body h5, .markdown-body h6 { font-size: 14.5px; }
.markdown-body p { margin: 8px 0; }
.markdown-body ul, .markdown-body ol { margin: 8px 0; padding-left: 22px; }
.markdown-body li { margin: 4px 0; }
.markdown-body blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--signal);
  background: var(--signal-soft);
  color: var(--text);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.markdown-body code {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.markdown-body pre {
  margin: 10px 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}
.markdown-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12.5px;
  white-space: pre;
}
.markdown-body strong { font-weight: 600; }
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13.5px;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 7px 11px;
  text-align: left;
  vertical-align: top;
}
.markdown-body th {
  background: var(--surface);
  font-weight: 600;
}
.markdown-body tbody tr:nth-child(even) { background: var(--surface); }

/* ---------- Panneau de ré-analyse (mis en évidence) ---------- */

.analysis-panel {
  border: 1px solid var(--signal);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--signal-soft);
  padding: 18px 20px;
}

.analysis-panel .card-title { color: var(--signal-strong); }

.analysis-panel .card-hint { color: var(--text); opacity: 0.75; }

.analysis-presets { margin-bottom: 12px; }

.analysis-history {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.analysis-entry {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.analysis-entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.analysis-entry-head .analysis-instruction {
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-body);
}

.analysis-entry-head time { font-family: var(--font-mono); flex-shrink: 0; }

/* ---------- Barre de sauvegarde ---------- */

.save-bar {
  position: sticky;
  bottom: 16px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-float);
}

.save-bar #save-result { flex: 1; }
.save-bar #save-result .alert { margin-bottom: 0; }

/* ---------- Divers ---------- */

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.disabled-zone { pointer-events: none; opacity: 0.55; }

[hidden] { display: none !important; }

.auth-page { padding-top: 12vh; }
.auth-page h1 { text-align: center; margin-bottom: 4px; }
.auth-page .subtitle { text-align: center; margin-left: auto; margin-right: auto; }

/* ---------- Onglets (page Paramètres) ---------- */

.tabbar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 10px 4px;
  margin-right: 20px;
  font-size: 14.5px;
  font-weight: 500;
  font-family: var(--font-body);
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-panel { display: flex; flex-direction: column; gap: 20px; }

/* ---------- Comptes / utilisateurs ---------- */

.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.user-row:last-child { border-bottom: none; }

.user-row .role-badge {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  margin-left: 8px;
  font-family: var(--font-mono);
}

.user-row button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
}

.user-row button:hover { color: var(--accent); }
.user-row button.danger { color: var(--danger); }
.user-row button.danger:hover { color: var(--danger); }

.user-row button:disabled {
  color: var(--text-faint);
  cursor: not-allowed;
}

.user-models-panel {
  padding: 4px 0 14px 0;
}

.model-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
}

/* ---------- Modèles de résumé ---------- */

.model-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  flex-wrap: wrap;
}

.model-row:last-child { border-bottom: none; }

.model-row .role-badge {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  margin-left: 8px;
  font-family: var(--font-mono);
}

.model-row .row-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
}

.model-row .row-actions button:hover { color: var(--accent); }
.model-row .row-actions button.danger { color: var(--danger); }
.model-row .row-actions button.danger:hover { color: var(--danger); }

/* ---------- Notebooks ---------- */

.btn.danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn.danger:hover { background: var(--danger-bg); }

.notebook-grid, .chat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.notebook-card, .chat-card-item { cursor: pointer; transition: border-color 0.15s ease; }
.notebook-card:hover, .chat-card-item:hover { border-color: var(--accent); }
.notebook-card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.notebook-card-title-row .card-title { display: block; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--accent); background: var(--surface-2); }
.icon-btn svg { width: 15px; height: 15px; }

.notebook-title-edit, .chat-title-edit { display: inline-flex; align-items: center; gap: 4px; }
.notebook-title-input, .chat-title-input {
  font-size: 26px;
  font-family: inherit;
  padding: 2px 6px;
  width: auto;
  min-width: 220px;
}

.source-row .badge { margin-left: 8px; }
.source-status-pending { color: var(--text-muted); }
.source-status-indexed { color: var(--success); border-color: var(--success-bg); background: var(--success-bg); }
.source-status-error { color: var(--danger); border-color: var(--danger-bg); background: var(--danger-bg); }

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 4px 2px;
}

.chat-message {
  border-radius: var(--radius);
  padding: 12px 14px;
  max-width: 85%;
}

.chat-message-user {
  align-self: flex-end;
  background: var(--accent-soft);
}

.chat-message-user .markdown-body p { margin: 0; }

.chat-message-actions {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}
.chat-message-assistant .chat-message-actions { justify-content: flex-start; }
.chat-message-actions .icon-btn { width: 22px; height: 22px; }
.chat-message-actions .icon-btn svg { width: 13px; height: 13px; }

.chat-message-assistant {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  max-width: 92%;
}

.chat-citations {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chat-citations-label {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
  margin-right: 2px;
}

.citation-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.citation-chip a,
.citation-chip span[title] {
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.citation-chip a:hover { text-decoration: underline; }

.citation-kind {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.7;
}

.citation-chip-web .citation-kind { color: var(--accent); opacity: 0.85; }

.citation-domain {
  color: var(--text-muted);
  opacity: 0.7;
  font-size: 11px;
  white-space: nowrap;
}
.citation-domain::before { content: '· '; }

.citation-location {
  opacity: 0.75;
  white-space: nowrap;
}
.citation-location::before { content: ' · '; }

/* Citations en ligne (crochets [nom-du-fichier, référence] / [web : titre]
   produits par le prompt notebook, voir mdRenderCitations dans
   public/js/markdown.js) : mêmes chips que .chat-citations en bas de
   message, réduites et surélevées pour rester discrètes dans le texte. */
.citation-chip-inline {
  font-size: 10.5px;
  padding: 1px 7px;
  margin: 0 2px;
  vertical-align: 2px;
  cursor: default;
}

.citation-chip-inline .citation-chip-inline-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.chat-message-status {
  color: var(--text-muted);
  font-style: italic;
  animation: chat-status-pulse 1.4s ease-in-out infinite;
}

@keyframes chat-status-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* Respecte les préférences de réduction de mouvement */
@media (prefers-reduced-motion: reduce) {
  .spinner, .progress-fill.indeterminate, .badge-live::before, .chat-message-status {
    animation: none;
  }
}
