/* ==========================================================================
   Assistant IA — Thomas Patout
   Feuille de style unique · thèmes clair / sombre · responsive · a11y
   --------------------------------------------------------------------------
   Sommaire
   01. Design tokens (variables)
   02. Reset & bases
   03. Utilitaires
   04. En-tête & marque
   05. Héros
   06. Recherche (formulaire, compteur, bouton)
   07. Exemples (pilules)
   08. Alertes / erreurs
   09. Cartes de résultat & chargement
   10. Réponse (prose), feedback, sources
   11. Pied de page
   12. Responsive
   13. Mouvement réduit & forced colors
   ========================================================================== */

/* 01. Design tokens ------------------------------------------------------- */
:root {
  color-scheme: light;

  --font-sans: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --font-mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;

  /* Surfaces */
  --bg: #f6f4ef;
  --surface: #fffefa;
  --surface-2: #f1efe8;
  --surface-3: #e7e4dc;
  --header-bg: rgba(246, 244, 239, 0.8);

  /* Texte */
  --text: #1a1f1c;
  --text-muted: #56615b;
  --text-subtle: #6b766f;

  /* Bordures */
  --border: #e2ded4;
  --border-strong: #cdc8bc;

  /* Accent (vert profond) */
  --accent: #175f4d;
  --accent-hover: #0f4b3c;
  --accent-soft: #e7f1ec;
  --accent-text: #145743;
  --accent-contrast: #ffffff;

  /* Sémantique */
  --danger: #9e352b;
  --danger-soft: #fbeeec;
  --danger-border: #efcac4;
  --danger-text: #7e2a22;

  --warning: #8a5a12;
  --warning-soft: #fbf3e3;
  --warning-border: #eeddb8;
  --warning-text: #6f4a10;

  /* Halos décoratifs */
  --glow-1: rgba(23, 95, 77, 0.13);
  --glow-2: rgba(196, 142, 78, 0.1);

  /* Focus & ombres */
  --ring-color: rgba(23, 95, 77, 0.28);
  --shadow-sm: 0 1px 2px rgba(31, 38, 33, 0.04), 0 8px 24px -18px rgba(31, 38, 33, 0.25);
  --shadow-md: 0 1px 2px rgba(31, 38, 33, 0.04), 0 24px 48px -30px rgba(31, 38, 33, 0.38);
  --shadow-btn: 0 10px 20px -12px rgba(23, 95, 77, 0.7);

  /* Rayons */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-pill: 999px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b0f0d;
  --surface: #131815;
  --surface-2: #1a211d;
  --surface-3: #232b26;
  --header-bg: rgba(11, 15, 13, 0.8);

  --text: #eef3ef;
  --text-muted: #aab5af;
  --text-subtle: #89958f;

  --border: #28322b;
  --border-strong: #3a463e;

  --accent: #74d6b9;
  --accent-hover: #93e3cb;
  --accent-soft: #16332a;
  --accent-text: #93e3cb;
  --accent-contrast: #062019;

  --danger: #f0a49d;
  --danger-soft: #2b1715;
  --danger-border: #4f2a26;
  --danger-text: #f3b3ad;

  --warning: #e2b96f;
  --warning-soft: #291f10;
  --warning-border: #4c3a1c;
  --warning-text: #f0cc8d;

  --glow-1: rgba(78, 190, 158, 0.12);
  --glow-2: rgba(196, 142, 78, 0.07);

  --ring-color: rgba(116, 214, 185, 0.38);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -18px rgba(0, 0, 0, 0.8);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.35), 0 24px 48px -30px rgba(0, 0, 0, 0.9);
  --shadow-btn: 0 10px 22px -12px rgba(0, 0, 0, 0.85);
}

/* 02. Reset & bases ------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 500px at 50% -12%, var(--glow-1), transparent 68%),
    radial-gradient(760px 460px at 92% 6%, var(--glow-2), transparent 62%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main {
  flex: 1 0 auto;
  padding-bottom: 1rem;
}

main:focus {
  outline: none;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

ul,
ol {
  margin-top: 0;
}

a {
  color: var(--accent-text);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

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

button,
textarea,
input {
  font: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

svg {
  display: block;
}

::selection {
  background: var(--accent);
  color: var(--accent-contrast);
}

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

[hidden] {
  display: none !important;
}

/* 03. Utilitaires --------------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1060px;
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 4vw, 2rem);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.7rem 1.05rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.88rem;
  font-weight: 650;
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transform: translateY(-160%);
  transition: transform 0.18s ease;
}

.skip-link:focus {
  transform: translateY(0);
  color: var(--accent-contrast);
}

/* 04. En-tête & marque ---------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.35rem 0.25rem 0.25rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-text strong {
  font-size: 0.9rem;
  font-weight: 650;
  letter-spacing: -0.005em;
}

.brand-text span {
  color: var(--text-subtle);
  font-size: 0.66rem;
  font-weight: 550;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

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

.theme-toggle:active {
  transform: scale(0.96);
}

.theme-toggle .icon {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-sun {
  display: none;
}

.theme-toggle .icon-moon {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

/* 05. Héros --------------------------------------------------------------- */
.hero {
  max-width: 850px;
  margin-inline: auto;
  padding-block: clamp(3rem, 7vw, 4.75rem) clamp(1.75rem, 4vw, 2.5rem);
  text-align: center;
  animation: rise-in 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1.45rem;
  padding: 0.38rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  box-shadow: var(--shadow-sm);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: pulse-dot 2.8s ease-in-out infinite;
}

.hero h1 {
  margin: 0 0 1.35rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(2.55rem, 7vw, 4.35rem);
  font-weight: 500;
  letter-spacing: -0.028em;
  line-height: 1.02;
  text-wrap: balance;
}

.hero h1 em {
  color: var(--accent-text);
  font-style: italic;
}

.hero-subtitle {
  max-width: 720px;
  margin: 0 auto;
  color: var(--text-muted);
  font-size: clamp(0.98rem, 2vw, 1.06rem);
  line-height: 1.7;
  text-wrap: pretty;
}

/* 06. Recherche ----------------------------------------------------------- */
.search {
  max-width: 820px;
  margin-inline: auto;
  animation: rise-in 0.55s 0.08s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.ask-form {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ask-form:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-md), 0 0 0 4px var(--ring-color);
}

/* État optionnel : formulaire en erreur de validation. */
.ask-form.has-error {
  border-color: var(--danger-border);
  box-shadow: var(--shadow-md), 0 0 0 4px var(--danger-soft);
}

.field {
  padding: 0.3rem 0.3rem 0;
}

#question-input {
  display: block;
  width: 100%;
  min-height: 6.9rem;
  max-height: 16rem;
  padding: 1.2rem 1.2rem 0.9rem;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.65;
  resize: vertical;
}

#question-input::placeholder {
  color: var(--text-subtle);
  opacity: 1;
}

#question-input:focus {
  outline: none;
}

.form-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.05rem 0.95rem 1.35rem;
}

.char-counter {
  margin: 0;
  color: var(--text-subtle);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

#char-current {
  color: var(--text-muted);
  font-weight: 650;
}

.char-sep {
  padding-inline: 0.2rem;
  opacity: 0.65;
}

.char-label {
  margin-left: 0.2rem;
}

.char-counter.is-near-limit {
  color: var(--warning-text);
}

.char-counter.is-near-limit #char-current {
  color: var(--warning-text);
}

.char-counter.is-over-limit {
  color: var(--danger-text);
  font-weight: 650;
}

.char-counter.is-over-limit #char-current {
  color: var(--danger-text);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.keyboard-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  color: var(--text-subtle);
  font-size: 0.7rem;
  white-space: nowrap;
}

.keyboard-hint kbd {
  padding: 0.14rem 0.36rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.66rem;
  font-weight: 600;
  line-height: 1.45;
}

/* Boutons ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 46px;
  padding: 0.7rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.btn-primary {
  min-width: 12.6rem;
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.72;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  filter: saturate(0.7);
}

.btn-arrow {
  width: 17px;
  height: 17px;
  transition: transform 0.18s ease;
}

.btn-primary:hover:not(:disabled) .btn-arrow {
  transform: translateX(2px);
}

/* Bascule visuelle de l'état de chargement du bouton. */
.btn-text--loading {
  display: none;
}

.btn .spinner {
  display: none;
}

.btn.is-loading .btn-text--idle {
  display: none;
}

.btn.is-loading .btn-text--loading {
  display: inline;
}

.btn.is-loading .btn-arrow {
  display: none;
}

.btn.is-loading .spinner {
  display: inline-block;
}

#ask-form[aria-busy="true"] .btn-primary {
  cursor: progress;
}

/* Spinner ---------------------------------------------------------------- */
.spinner {
  width: 15px;
  height: 15px;
  flex: none;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-lg {
  width: 28px;
  height: 28px;
  border-width: 2.5px;
  color: var(--accent);
}

/* 07. Exemples ------------------------------------------------------------ */
.examples {
  margin-top: 1.35rem;
}

.examples-label {
  margin: 0 0 0.6rem;
  color: var(--text-subtle);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
  transform: translateY(-1px);
}

.chip:active {
  transform: translateY(0);
}

.chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent);
}

/* 08. Alertes / erreurs --------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  width: 100%;
  max-width: 820px;
  margin: 1.25rem auto 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: var(--danger-text);
  animation: rise-in 0.3s ease both;
}

.alert-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: rgba(158, 53, 43, 0.1);
  color: var(--danger);
}

.alert-icon svg {
  width: 19px;
  height: 19px;
}

.alert-content {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 0.05rem;
}

.alert-title {
  margin: 0 0 0.2rem;
  color: var(--danger-text);
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.4;
}

.alert-message {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.alert-action {
  flex: none;
  align-self: center;
  padding: 0.45rem 0.8rem;
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--danger-text);
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.alert-action:hover {
  background: rgba(158, 53, 43, 0.08);
}

.alert-action:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 3px;
}

.alert--warning {
  border-color: var(--warning-border);
  background: var(--warning-soft);
  color: var(--warning-text);
}

.alert--warning .alert-title {
  color: var(--warning-text);
}

.alert--warning .alert-icon {
  background: rgba(138, 90, 18, 0.12);
  color: var(--warning);
}

.alert--warning .alert-action {
  color: var(--warning-text);
}

.alert--warning .alert-action:hover {
  background: rgba(138, 90, 18, 0.1);
}

.alert--info {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--accent-text);
}

.alert--info .alert-title {
  color: var(--text);
}

.alert--info .alert-icon {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.alert--info .alert-action {
  color: var(--accent-text);
}

/* 09. Cartes de résultat & chargement ------------------------------------- */
.result-card {
  position: relative;
  width: 100%;
  max-width: 820px;
  margin: 2.75rem auto 0;
  padding: clamp(1.3rem, 3.4vw, 2rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.result-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.45;
  pointer-events: none;
}

.answer-card.is-fresh {
  animation: rise-in 0.45s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.loading-card {
  animation: rise-in 0.3s ease both;
}

.loading-head {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin-bottom: 1.6rem;
}

.loading-head .spinner-lg {
  margin-top: 0.2rem;
}

.loading-title {
  margin: 0 0 0.2rem;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.4;
}

.loading-message {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.skeleton {
  display: grid;
  gap: 0.72rem;
}

.skeleton-line {
  display: block;
  height: 0.78rem;
  border-radius: var(--radius-pill);
  background: linear-gradient(
    90deg,
    var(--surface-2) 20%,
    var(--surface-3) 38%,
    var(--surface-2) 56%
  );
  background-size: 240% 100%;
  animation: shimmer 1.45s ease-in-out infinite;
}

.skeleton-line--short {
  margin-top: 0.35rem;
}

.skeleton-line--w92 {
  width: 92%;
}

.skeleton-line--w100 {
  width: 100%;
}

.skeleton-line--w84 {
  width: 84%;
}

.skeleton-line--w58 {
  width: 58%;
}

/* 10. Réponse ------------------------------------------------------------- */
.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.2rem;
}

.result-header-main {
  min-width: 0;
}

.result-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.55rem;
  color: var(--accent-text);
  font-size: 0.66rem;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.answer-question {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.7vw, 1.7rem);
  font-weight: 500;
  letter-spacing: -0.012em;
  line-height: 1.28;
  text-wrap: pretty;
}

.answer-question:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
  border-radius: 4px;
}

.result-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  flex: none;
  margin: 0;
  padding-top: 0.15rem;
  color: var(--text-subtle);
  font-size: 0.73rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.meta-sep {
  opacity: 0.6;
}

/* Prose ------------------------------------------------------------------ */
.prose {
  color: var(--text);
  font-size: 0.96rem;
  line-height: 1.72;
}

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

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

.prose p {
  margin: 0 0 0.85rem;
}

.prose strong {
  font-weight: 650;
}

.prose ul,
.prose ol {
  margin: 0 0 0.95rem;
  padding-left: 1.3rem;
}

.prose li {
  margin-bottom: 0.35rem;
  padding-left: 0.12rem;
}

.prose li:last-child {
  margin-bottom: 0;
}

.prose li::marker {
  color: var(--accent);
}

.prose h2,
.prose h3 {
  margin: 1.3rem 0 0.55rem;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.35;
}

.prose a {
  color: var(--accent-text);
  font-weight: 550;
}

.prose code {
  padding: 0.08em 0.35em;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.prose blockquote {
  margin: 1rem 0;
  padding: 0.2rem 0 0.2rem 0.9rem;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}

/* Texte de réponse affiché en flux (streaming) : les retours à la ligne du
   modèle sont conservés sans injection de HTML. */
.prose .stream-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Curseur clignotant pendant la génération. */
.answer-card.is-streaming .stream-text::after {
  content: "";
  display: inline-block;
  width: 0.5ch;
  height: 1.05em;
  margin-left: 0.12em;
  border-radius: 1px;
  background: var(--accent);
  vertical-align: -0.16em;
  animation: caret-blink 1s steps(2, start) infinite;
}

@keyframes caret-blink {
  to {
    visibility: hidden;
  }
}

/* Page de confidentialité ------------------------------------------------- */
.legal-page {
  max-width: 46rem;
  padding-block: 3rem 3.5rem;
}

.legal-page h1 {
  margin: 0.4rem 0 1.6rem;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.2rem);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.legal-page hr {
  margin: 2rem 0 1.2rem;
  border: 0;
  border-top: 1px solid var(--border);
}

.legal-note {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.legal-back {
  margin: 2rem 0 0;
}

/* Feedback --------------------------------------------------------------- */
.feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.9rem;
  margin-top: 1.6rem;
  padding-top: 1.05rem;
  border-top: 1px solid var(--border);
}

.feedback-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.feedback-buttons {
  display: flex;
  gap: 0.45rem;
}

.feedback-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 34px;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 550;
  cursor: pointer;
  transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.feedback-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.feedback-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.feedback-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent);
}

.feedback-emoji {
  font-size: 0.92rem;
  line-height: 1;
}

.feedback-status {
  flex-basis: 100%;
  min-height: 1.05rem;
  margin: 0;
  color: var(--accent-text);
  font-size: 0.76rem;
  line-height: 1.4;
}

/* Ne réserve pas de ligne vide tant qu'aucun retour n'est affiché. */
.feedback-status:empty {
  display: none;
}

/* Sources ---------------------------------------------------------------- */
.sources {
  margin-top: 1.45rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--border);
}

.sources-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.sources-title {
  margin: 0;
  color: var(--text-subtle);
  font-size: 0.67rem;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.sources-count {
  color: var(--text-subtle);
  font-size: 0.73rem;
}

.sources-list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.source-item {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.source-item:hover {
  border-color: var(--border-strong);
}

.source-item.is-open {
  border-color: var(--accent);
  background: var(--surface);
}

.source-link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  padding: 0.68rem 0.85rem;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.18s ease;
}

.source-item:not(.is-open) .source-link:hover {
  background: var(--accent-soft);
}

.source-item.is-open .source-link {
  background: var(--accent-soft);
}

.source-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
  border-radius: 11px;
}

.source-link:disabled {
  color: var(--text);
  cursor: default;
  opacity: 1;
}

.source-num {
  flex: none;
  width: 1.5rem;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.source-body {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  flex: 1 1 auto;
  min-width: 0;
}

.source-title {
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.4;
}

.source-excerpt {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-file {
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  line-height: 1.45;
  opacity: 0.85;
}

.source-chevron {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--text-subtle);
  transition: color 0.18s ease, transform 0.2s ease;
}

.source-link:hover .source-chevron {
  color: var(--accent-text);
}

.source-item.is-open .source-chevron {
  color: var(--accent-text);
  transform: rotate(180deg);
}

/* Panneau déplié : extrait complet du chunk utilisé par le RAG. */
.source-detail {
  padding: 0.85rem 0.95rem 0.95rem 3.15rem;
  border-top: 1px dashed var(--border);
  background: var(--surface);
  animation: source-open 0.2s ease both;
}

.source-detail-label {
  margin: 0 0 0.4rem;
  color: var(--text-subtle);
  font-size: 0.63rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.source-detail-text {
  max-height: 20rem;
  margin: 0;
  padding-right: 0.2rem;
  overflow: auto;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.65;
  white-space: pre-line;
}

/* 11. Pied de page -------------------------------------------------------- */
.site-footer {
  margin-top: 5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-inner {
  display: grid;
  gap: 1.5rem;
  padding-block: 2rem 2.4rem;
}

.disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 1.05rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.disclaimer-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.disclaimer-icon svg {
  width: 20px;
  height: 20px;
}

.disclaimer h2 {
  margin: 0 0 0.3rem;
  color: var(--text);
  font-size: 0.67rem;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.disclaimer p {
  max-width: 82ch;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.65;
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-note {
  margin: 0;
  color: var(--text-subtle);
  font-size: 0.78rem;
}

.footer-note strong {
  color: var(--text-muted);
  font-weight: 600;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 34px;
  padding: 0.3rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 550;
  text-decoration: none;
  transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.footer-link svg {
  width: 13px;
  height: 13px;
  opacity: 0.7;
}

.footer-link:hover {
  border-color: var(--border);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.footer-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent);
}

/* Contact : copie de l'adresse email + confirmation ----------------------- */
.footer-contact {
  position: relative;
  display: inline-flex;
}

.copy-tooltip {
  position: absolute;
  bottom: calc(100% + 0.45rem);
  left: 0;
  z-index: 10;
  max-width: min(18rem, 80vw);
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.35;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  pointer-events: none;
}

.copy-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 12. Responsive ---------------------------------------------------------- */
@media (max-width: 760px) {
  .header-inner {
    min-height: 62px;
  }

  .hero {
    padding-top: 2.9rem;
  }

  .form-bar {
    flex-wrap: wrap;
    gap: 0.65rem;
    padding: 0 0.95rem 0.95rem 1.2rem;
  }

  .form-actions {
    margin-left: auto;
  }

  .keyboard-hint {
    display: none;
  }

  .result-header {
    flex-direction: column;
    gap: 0.45rem;
  }

  .result-meta {
    padding-top: 0;
  }

  .source-excerpt {
    display: -webkit-box;
    overflow: hidden;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .source-detail {
    padding-left: 0.95rem;
  }
}

@media (max-width: 560px) {
  .brand-text span {
    display: none;
  }

  .hero h1 br {
    display: none;
  }

  .hero-subtitle {
    font-size: 0.96rem;
  }

  #question-input {
    min-height: 6.2rem;
    padding: 1.05rem 1rem 0.8rem;
    font-size: 1rem;
  }

  .form-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
    padding: 0 0.9rem 0.9rem;
  }

  .char-counter {
    padding-left: 0.1rem;
  }

  .form-actions {
    width: 100%;
    margin-left: 0;
  }

  .btn {
    width: 100%;
  }

  .btn-primary {
    min-width: 0;
  }

  .chip {
    padding: 0.42rem 0.72rem;
    font-size: 0.77rem;
  }

  .result-card {
    padding: 1.15rem;
    border-radius: 18px;
  }

  .answer-question {
    font-size: 1.28rem;
  }

  .prose {
    font-size: 0.93rem;
  }

  .feedback {
    align-items: flex-start;
  }

  .feedback-label {
    flex-basis: 100%;
  }

  .alert {
    flex-wrap: wrap;
  }

  .alert-action {
    margin-left: 2.7rem;
  }

  .disclaimer {
    padding: 0.95rem 1rem;
  }

  .disclaimer-icon {
    width: 32px;
    height: 32px;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* 13. Mouvement réduit & forced colors ------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* Un spinner figé laisse croire que la page est bloquée : on conserve une
     rotation lente (indicateur d'activité essentiel) et un scintillement doux. */
  .spinner {
    animation: spin 1.4s linear infinite !important;
  }

  .skeleton-line {
    animation: shimmer 2.4s ease-in-out infinite !important;
  }
}

@media (forced-colors: active) {
  .btn,
  .chip,
  .theme-toggle,
  .feedback-btn,
  .source-link,
  .footer-link,
  .alert,
  .ask-form,
  .result-card {
    border: 1px solid ButtonText;
  }

  .status-dot,
  .pulse-dot,
  .skeleton-line {
    background: Highlight;
  }
}

/* Animations ------------------------------------------------------------- */
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes shimmer {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

@keyframes pulse-dot {
  0%,
  100% {
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  50% {
    box-shadow: 0 0 0 5px var(--accent-soft);
  }
}

@keyframes source-open {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
