/* ===== Charte MGPAP : bleu #0071B6, vert #95C11F ===== */
:root {
  --blue: #0071b6;
  --blue-600: #005f99;
  --blue-700: #004d7d;
  --blue-50: #eaf4fb;
  --blue-100: #d3e8f6;
  --green: #95c11f;
  --green-600: #7aa114;
  --green-700: #5e7d0c;
  --green-50: #f3f9e6;
  --green-100: #e4f1c4;

  --bg: #f4f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f2233;
  --text-2: #3b4f61;
  --muted: #6b7f91;
  --line: #e2e9f0;
  --line-2: #edf2f6;
  --warn: #b45309;
  --warn-bg: #fff7ea;
  --danger: #dc2626;
  --code-bg: var(--blue-50);
  --code-fg: var(--blue-700);
  --shadow-sm: 0 1px 2px rgba(15, 34, 51, .06);
  --shadow: 0 1px 3px rgba(15, 34, 51, .06), 0 8px 24px rgba(15, 34, 51, .06);
  --shadow-lg: 0 20px 60px rgba(0, 54, 92, .18);
  --radius: 14px;
  --font: Inter, "Noto Sans Arabic", system-ui, -apple-system, sans-serif;
  --font-ar: "Noto Sans Arabic", Inter, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1520;
    --surface: #111e2b;
    --surface-2: #0f1a26;
    --text: #e6eef5;
    --text-2: #b9c8d6;
    --muted: #8296a8;
    --line: #1f3142;
    --line-2: #182736;
    --blue-50: #0d2a40;
    --blue-100: #123552;
    --green-50: #1b2a0c;
    --green-100: #243a0e;
    --green-700: #a9d13a;
    --warn: #f5b041;
    --warn-bg: #2d2210;
    --code-bg: #0e2c44;
    --code-fg: #8cc8f0;
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
[dir="rtl"] { font-family: var(--font-ar); }

.app { height: 100%; height: 100dvh; display: flex; flex-direction: column; }

/* ===== Barre du haut ===== */
.topbar {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  z-index: 2;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px;
  background: linear-gradient(90deg, var(--blue) 0 50%, var(--green) 50% 100%);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { height: 52px; width: auto; display: block; }
.brand-divider { width: 1px; height: 36px; background: var(--line); }
.brand-title h1 {
  margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.01em; color: var(--blue);
  display: flex; align-items: center; gap: 8px;
}
.ia-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  color: #fff; background: var(--green); border-radius: 6px; padding: 2px 6px;
}
.brand-title p { margin: 1px 0 0; font-size: 13px; color: var(--muted); font-weight: 500; }

.top-actions { display: flex; align-items: center; gap: 12px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
  white-space: nowrap;
}
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-pill.ok i { background: var(--green); box-shadow: 0 0 0 3px var(--green-100); }
.status-pill.busy i { background: var(--blue); animation: pulse-dot 1s infinite; }
.status-pill.speaking i { background: var(--green); animation: pulse-dot .6s infinite; }
.status-pill.err i { background: var(--danger); }
@keyframes pulse-dot { 50% { transform: scale(1.5); opacity: .6; } }

.voice-select {
  display: inline-flex; align-items: center; gap: 6px; color: var(--blue);
  border: 1px solid var(--line); border-radius: 10px; padding: 0 4px 0 10px; background: var(--surface);
  transition: border-color .15s;
}
.voice-select:hover, .voice-select:focus-within { border-color: var(--blue); }
.voice-select select {
  appearance: none; -webkit-appearance: none; border: none; background: transparent; color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600; padding: 8px 22px 8px 2px; cursor: pointer; outline: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 10px) 52%, calc(100% - 6px) 52%; background-size: 4px 4px; background-repeat: no-repeat;
}
.voice-select select option { color: #0f2233; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 36px; height: 20px; border-radius: 999px; background: var(--line);
  position: relative; transition: background .2s;
}
.switch .thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track .thumb { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--blue); outline-offset: 2px; }
.switch-label { font-size: 13px; font-weight: 600; color: var(--text-2); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text-2); }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-soft { background: var(--blue-50); border: 1px solid transparent; color: var(--blue); }
.btn-soft:not(:disabled):hover { background: var(--blue-100); }

/* ===== Mise en page ===== */
.layout {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px;
  width: 100%; max-width: 1320px; margin: 0 auto; padding: 20px 24px;
}
.chat-col {
  min-height: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  overflow: hidden;
}
.chat { flex: 1; overflow-y: auto; padding: 24px 28px 12px; display: flex; flex-direction: column; gap: 18px; }

/* ===== Accueil ===== */
.welcome { margin: auto; max-width: 720px; text-align: center; padding: 16px 0 8px; }
.hero-avatar, .bot-avatar, .wake-avatar {
  display: grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 800;
  background: conic-gradient(from 200deg, var(--blue) 0 50%, var(--green) 50% 100%);
  position: relative;
}
.hero-avatar::before, .bot-avatar::before, .wake-avatar::before {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--blue);
}
.hero-avatar span, .bot-avatar span, .wake-avatar > span { position: relative; }
.hero-avatar { width: 72px; height: 72px; font-size: 30px; margin: 0 auto 14px; box-shadow: 0 10px 30px rgba(0,113,182,.25); }
.hero-sub { margin: -2px 0 10px; color: var(--muted); font-size: 13.5px; font-weight: 600; letter-spacing: .02em; }
.welcome h2 { margin: 0 0 6px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.welcome .hello { margin: 0 auto 10px; font-size: 18px; color: var(--blue); font-weight: 600; max-width: 620px; line-height: 1.7; }
.welcome .lead { margin: 0 auto 22px; color: var(--text-2); max-width: 560px; }
.welcome .lead strong { color: var(--text); }
.categories { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; text-align: left; }
.cat {
  display: flex; align-items: center; gap: 12px; cursor: pointer; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.cat:hover { border-color: var(--blue); box-shadow: var(--shadow); transform: translateY(-1px); }
.cat-icon {
  flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--blue-50); color: var(--blue);
}
.cat:nth-child(even) .cat-icon { background: var(--green-50); color: var(--green-700); }
.cat-icon svg { width: 20px; height: 20px; }
.cat-text { display: flex; flex-direction: column; min-width: 0; }
.cat-text b { font-size: 13.5px; font-weight: 700; }
.cat-text small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Messages ===== */
.msg { display: flex; gap: 12px; max-width: 100%; animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.msg.user { justify-content: flex-end; }
.user-bubble {
  max-width: min(75%, 620px);
  background: var(--blue); color: #fff;
  padding: 10px 14px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap;
  box-shadow: 0 4px 14px rgba(0,113,182,.18);
}
.user-bubble .tag { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; opacity: .85; margin-bottom: 2px; }

.bot-avatar { flex: none; width: 36px; height: 36px; font-size: 15px; margin-top: 2px; }
.msg.speaking .bot-avatar { animation: speak-ring 1s ease-in-out infinite; }
@keyframes speak-ring { 50% { box-shadow: 0 0 0 6px var(--green-100); } }
.bot-body { flex: 1; min-width: 0; max-width: 760px; display: flex; flex-direction: column; gap: 10px; }

.speech {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--green-50); border: 1px solid var(--green-100);
  padding: 12px 14px; border-radius: 4px 16px 16px 16px;
  font-family: var(--font-ar); font-size: 16.5px; line-height: 1.8; color: var(--text);
}
.speech-text { flex: 1; }
.replay {
  flex: none; width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--surface); color: var(--green-700); display: grid; place-items: center;
  box-shadow: var(--shadow-sm); transition: transform .15s;
}
.replay:hover { transform: scale(1.08); }
.eq { display: none; gap: 2px; align-items: flex-end; height: 14px; }
.eq i { width: 3px; background: currentColor; border-radius: 2px; animation: eq .8s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: .15s; } .eq i:nth-child(3) { animation-delay: .3s; } .eq i:nth-child(4) { animation-delay: .45s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }
.msg.speaking .replay .play-icon { display: none; }
.msg.speaking .replay .eq { display: flex; }

/* Fiche acte */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--line-2); background: var(--surface-2);
}
.type-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  letter-spacing: .03em; text-transform: uppercase; border-radius: 999px; padding: 4px 10px;
}
.type-pill.exact { background: var(--green-50); color: var(--green-700); border: 1px solid var(--green-100); }
.type-pill.assim { background: var(--blue-50); color: var(--blue); border: 1px solid var(--blue-100); }
.type-pill.interne { background: var(--blue); color: #fff; border: 1px solid var(--blue); }
.verify { font-size: 12px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.verify.ok { color: var(--green-700); }
.verify.bad { color: var(--warn); }

.card-main { display: grid; grid-template-columns: auto 1fr; border-bottom: 1px solid var(--line-2); }
.kv { padding: 14px 18px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv + .kv { border-left: 1px solid var(--line-2); }
.kv label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kv .big { font-size: 26px; font-weight: 800; letter-spacing: -.01em; line-height: 1.25; display: flex; align-items: center; gap: 10px; }
.kv.code .big { font-family: var(--mono); color: var(--blue); }
.kv small { font-size: 13px; color: var(--text-2); font-weight: 500; }
.copy {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer;
  width: 28px; height: 28px; border-radius: 8px; display: inline-grid; place-items: center;
  transition: color .15s, border-color .15s; flex: none;
}
.copy:hover { color: var(--blue); border-color: var(--blue); }
.copy.done { color: var(--green-700); border-color: var(--green); }

.card-body { padding: 12px 18px 14px; display: flex; flex-direction: column; gap: 8px; }
.card-body:empty { display: none; }
.libelle { font-size: 15px; font-weight: 600; color: var(--text); }
.ref { font-size: 13px; color: var(--muted); }
.why { font-size: 14px; color: var(--text-2); background: var(--blue-50); border-radius: 10px; padding: 8px 12px; }
.why b, .warn b { font-weight: 700; }
.why b { color: var(--blue); }
.warn { font-size: 13.5px; color: var(--warn); background: var(--warn-bg); border-radius: 10px; padding: 8px 12px; }
.alts { border-top: 1px solid var(--line-2); }
.alts summary {
  cursor: pointer; list-style: none; padding: 10px 18px; font-size: 13px; font-weight: 700; color: var(--text-2);
  display: flex; align-items: center; gap: 6px;
}
.alts summary::-webkit-details-marker { display: none; }
.alts summary::before { content: "▸"; transition: transform .15s; color: var(--muted); }
.alts[open] summary::before { transform: rotate(90deg); }
.alt { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 8px 18px; border-top: 1px dashed var(--line-2); font-size: 13.5px; }
.alt-lib { color: var(--text-2); }
.alt-cot { font-weight: 700; white-space: nowrap; }
code, .chip-code {
  font-family: var(--mono); font-weight: 700; font-size: 13px;
  background: var(--code-bg); color: var(--code-fg); padding: 2px 7px; border-radius: 6px; white-space: nowrap;
}
.plain { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow-sm); }
.plain p { margin: 0 0 6px; } .plain p:last-child { margin: 0; }
.plain ul { margin: 4px 0; padding-left: 18px; }

.meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 10px; align-items: center; padding-left: 2px; }
.typing { display: inline-flex; gap: 5px; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; width: fit-content; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); animation: blink 1.1s infinite; }
.typing i:nth-child(2) { background: var(--green); animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
.error { color: var(--danger); background: var(--warn-bg); border-radius: 10px; padding: 10px 14px; }

/* ===== Saisie ===== */
.composer { border-top: 1px solid var(--line); padding: 12px 20px 10px; background: var(--surface); }
form { display: flex; align-items: flex-end; gap: 10px; }
textarea {
  flex: 1; resize: none; max-height: 160px; min-height: 48px;
  border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-50); background: var(--surface); }
textarea::placeholder { color: var(--muted); }
.mic, .send {
  flex: none; width: 48px; height: 48px; border-radius: 14px; border: none; cursor: pointer;
  display: grid; place-items: center; transition: transform .1s, background .15s, box-shadow .15s;
}
.mic:active, .send:active { transform: scale(.96); }
.send { background: var(--blue); color: #fff; box-shadow: 0 6px 16px rgba(0,113,182,.25); }
.send:hover { background: var(--blue-600); }
.send:disabled { opacity: .45; cursor: default; box-shadow: none; }
.mic { background: var(--green); color: #fff; box-shadow: 0 6px 16px rgba(149,193,31,.3); }
.mic:hover { background: var(--green-600); }
.mic .i-stop { display: none; }
.mic.recording { background: var(--danger); box-shadow: 0 0 0 6px rgba(220,38,38,.15); animation: rec-pulse 1.2s infinite; }
.mic.recording .i-mic { display: none; }
.mic.recording .i-stop { display: block; }
.mic.busy { opacity: .6; pointer-events: none; }
@keyframes rec-pulse { 50% { box-shadow: 0 0 0 12px rgba(220,38,38,.05); } }

.rec-panel {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px;
}
.rec-panel[hidden] { display: none; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse-dot 1s infinite; flex: none; }
.meter { display: flex; align-items: center; gap: 3px; height: 26px; }
.meter i { width: 4px; height: 4px; border-radius: 2px; background: var(--green); transition: height .08s; }
.rec-label { flex: 1; font-size: 13px; color: var(--text-2); }
.rec-time { font-family: var(--mono); font-size: 13px; color: var(--muted); }

.composer-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--muted); min-height: 18px; }
.status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint { white-space: nowrap; }
.hint kbd {
  font-family: var(--font); font-size: 11px; font-weight: 600; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: 0 5px; background: var(--surface-2);
}

/* ===== Panneau dossier ===== */
.side { min-height: 0; display: flex; flex-direction: column; gap: 14px; }
.side-card {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden;
}
.side-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 16px 16px 12px; border-bottom: 1px solid var(--line-2); }
.side-head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.side-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.session-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; counter-reset: act; }
.session-list .empty { color: var(--muted); font-size: 13px; padding: 16px 10px; text-align: center; line-height: 1.6; }
.s-item {
  counter-increment: act; display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: start;
  padding: 10px; border-radius: 12px; cursor: pointer; transition: background .15s;
}
.s-item:hover { background: var(--surface-2); }
.s-item::before {
  content: counter(act); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--blue-50); color: var(--blue);
}
.s-main { min-width: 0; }
.s-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.s-cot { font-weight: 800; font-size: 14px; }
.s-q { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.s-type { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 5px; }
.s-type.exact { background: var(--green-50); color: var(--green-700); }
.s-type.assim { background: var(--blue-50); color: var(--blue); }
.s-type.interne { background: var(--blue); color: #fff; }
.side-note {
  display: flex; gap: 10px; align-items: flex-start; font-size: 12px; color: var(--muted); line-height: 1.55;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
}
.side-note svg { flex: none; color: var(--blue); margin-top: 1px; }
.side-note p { margin: 0; }

/* ===== Réveil ===== */
.wake {
  position: fixed; inset: 0; z-index: 20; border: none; cursor: pointer; padding: 16px;
  display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 20% 0%, rgba(0,113,182,.18), transparent 60%),
              radial-gradient(900px 500px at 100% 100%, rgba(149,193,31,.18), transparent 60%),
              color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
}
.wake.hidden { display: none; }
.wake-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 32px 40px 28px;
  box-shadow: var(--shadow-lg); max-width: 420px; width: 100%;
}
.wake-logo { height: 64px; width: auto; }
.wake-avatar { width: 88px; height: 88px; font-size: 36px; margin-top: 6px; }
.wake-avatar .z {
  position: absolute; right: -4px; top: 0; font-style: normal; font-weight: 800; color: var(--blue);
  opacity: 0; animation: zz 3s infinite;
}
.wake-avatar .z2 { animation-delay: 1s; font-size: 20px; } .wake-avatar .z3 { animation-delay: 2s; font-size: 24px; }
@keyframes zz { 0% { opacity: 0; transform: translate(0, 0); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(18px, -30px); } }
.wake-title { font-size: 22px; font-weight: 800; color: var(--text); }
.wake-sub { font-size: 13.5px; color: var(--muted); }
.wake-btn {
  margin-top: 8px; background: var(--blue); color: #fff; font-weight: 700; padding: 12px 22px; border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,113,182,.3); transition: background .15s, transform .15s;
}
.wake:hover .wake-btn { background: var(--blue-600); transform: translateY(-1px); }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--surface); font-size: 13px; font-weight: 600;
  padding: 9px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); transition: opacity .2s, transform .2s; z-index: 30;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== Responsive ===== */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: none; }
}
@media (max-width: 760px) {
  .topbar { padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); }
  .logo { height: 40px; }
  .brand-title p, .status-pill, #clearBtn span, .hint, .switch-label { display: none; }
  .voice-select { padding-left: 8px; }
  .voice-select svg { display: none; }
  .voice-select select { font-size: 12px; max-width: 110px; text-overflow: ellipsis; }
  .top-actions { gap: 8px; }
  textarea { font-size: 16px; } /* évite le zoom automatique sur iPhone */
  .composer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .welcome { padding-top: 4px; }
  .hero-avatar { width: 56px; height: 56px; font-size: 24px; margin-bottom: 10px; }
  .welcome h2 { font-size: 22px; }
  .welcome .hello { font-size: 16.5px; }
  .welcome .lead { font-size: 14px; margin-bottom: 16px; }
  .cat { padding: 10px; gap: 10px; }
  .cat-icon { width: 32px; height: 32px; }
  .cat-text b { font-size: 13px; }
  .layout { padding: 0; }
  .chat-col { border-radius: 0; border: none; }
  .chat { padding: 16px 14px 8px; }
  .composer { padding: 10px 12px; }
  .categories { grid-template-columns: 1fr 1fr; }
  .user-bubble { max-width: 88%; }
  .bot-avatar { display: none; }
  .kv .big { font-size: 21px; }
  .alt { grid-template-columns: auto 1fr auto; }
  .alt .copy { display: none; }
}
@media (max-width: 420px) { .cat-text small { display: none; } }

/* ===== Connexion ===== */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 20% 0%, rgba(0,113,182,.14), transparent 60%),
              radial-gradient(900px 500px at 100% 100%, rgba(149,193,31,.14), transparent 60%), var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 32px 28px 26px; box-shadow: var(--shadow-lg);
}
.login-logo { height: 72px; width: auto; }
.login-card h1 { margin: 6px 0 0; font-size: 24px; font-weight: 800; color: var(--blue); display: flex; align-items: center; gap: 8px; }
.login-sub { margin: 0 0 10px; color: var(--muted); font-size: 13.5px; }
.login-card label { align-self: flex-start; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.login-card input {
  width: 100%; font: inherit; font-size: 20px; letter-spacing: .3em; text-align: center;
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--text);
}
.login-card .name-input { font-size: 16px; letter-spacing: normal; text-align: left; }
.login-card .opt { text-transform: none; letter-spacing: 0; font-weight: 500; }
.login-card input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-50); }
.login-card .wake-btn { width: 100%; border: none; cursor: pointer; font: inherit; font-weight: 700; }
.login-error { margin: 0; color: var(--danger); font-size: 13px; font-weight: 600; }
.login-note { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ===== Accès téléphone ===== */
.modal {
  position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 25, 40, .45); backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative; width: 100%; max-width: 420px; background: var(--surface); border-radius: 22px; padding: 26px 26px 22px;
  box-shadow: var(--shadow-lg); text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center;
}
.modal-card h3 { margin: 0; font-size: 19px; font-weight: 800; }
.modal-close {
  position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--surface-2); color: var(--muted); font-size: 18px; line-height: 1;
}
.qr { background: #fff; padding: 12px; border-radius: 14px; border: 1px solid var(--line); }
.qr img, .qr canvas { display: block; }
.phone-url { font-family: var(--mono); font-size: 12.5px; color: var(--blue); word-break: break-all; background: var(--blue-50); padding: 8px 10px; border-radius: 10px; }
.phone-code { font-size: 14px; color: var(--text-2); }
.phone-code b { font-family: var(--mono); font-size: 18px; letter-spacing: .15em; color: var(--text); }
.phone-steps { text-align: left; margin: 0; padding-left: 20px; font-size: 13px; color: var(--text-2); line-height: 1.6; }
.phone-warn { font-size: 12px; color: var(--muted); margin: 0; }
@media (max-width: 760px) { #phoneBtn { display: none; } #userName { display: none; } .user-btn { padding: 6px; } }
.side-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ===== Administration ===== */
:root { --chart-q: #0071b6; --chart-c: #5e7d0c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chart-q: #2f8ad0; --chart-c: #749a14; } }
.admin-body { min-height: 100%; height: auto; }
.admin-badge { background: var(--blue); }
.admin { max-width: 1320px; margin: 0 auto; padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 18px; }
.admin-body .login { min-height: calc(100vh - 80px); }
a.btn { text-decoration: none; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.kpi.warn { border-color: var(--warn); background: var(--warn-bg); }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--text); white-space: nowrap; }
.kpi-sub { font-size: 12px; color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line-2); }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 800; }
.panel-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2.wide-left { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.side-stack { display: flex; flex-direction: column; gap: 18px; }

.table-wrap { overflow-x: auto; }
.table-wrap.tall { max-height: 520px; overflow-y: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 14px; background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.table td { padding: 10px 14px; border-top: 1px solid var(--line-2); vertical-align: top; }
.table tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.table .q { min-width: 220px; max-width: 360px; }
.table .last-q { max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.is-revoked td { opacity: .6; }
.empty-row { text-align: center; color: var(--muted); padding: 20px !important; }
.dev-name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.dev-meta { font-size: 12px; color: var(--muted); }
.icon-btn { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 0 4px; border-radius: 6px; }
.icon-btn:hover { color: var(--blue); background: var(--blue-50); }
.actions { white-space: nowrap; text-align: right; }
.actions .btn + .btn { margin-left: 6px; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn-danger { background: var(--danger); color: #fff; border: 1px solid var(--danger); }
.btn-danger:hover { filter: brightness(1.08); }
.btn-danger-ghost { background: transparent; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }

.st { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.st-online { background: var(--green-50); color: var(--green-700); }
.st-idle { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.st-revoked { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.st-local { background: var(--blue-50); color: var(--blue); }
.tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 5px; margin-left: 4px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.tag.assim { background: var(--blue-50); color: var(--blue); border-color: transparent; }
.tag.bad { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

.chart { padding: 10px 14px 12px; }
.chart svg { width: 100%; height: auto; display: block; }
.grid-line { stroke: var(--line-2); stroke-width: 1; }
.base-line { stroke: var(--line); stroke-width: 1; }
.axis-label { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
.bar .hit { fill: transparent; }
.bar.hover .hit { fill: var(--surface-2); }
.tooltip {
  position: fixed; z-index: 40; pointer-events: none; background: var(--text); color: var(--surface);
  font-size: 12.5px; padding: 7px 10px; border-radius: 8px; box-shadow: var(--shadow-lg); line-height: 1.4;
}
.table-view summary { cursor: pointer; padding: 12px 18px; font-size: 13px; font-weight: 700; color: var(--text-2); }

.top-codes { list-style: none; margin: 0; padding: 8px 12px 12px; counter-reset: tc; }
.top-codes li { counter-increment: tc; display: grid; grid-template-columns: 22px auto 1fr auto; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px dashed var(--line-2); font-size: 13px; }
.top-codes li::before { content: counter(tc); color: var(--muted); font-weight: 700; font-size: 12px; }
.top-codes li.empty-row { display: block; }
.top-codes li.empty-row::before { content: none; }
.tc-cot { color: var(--text-2); }
.quality { list-style: none; margin: 0; padding: 6px 16px 12px; }
.quality li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line-2); font-size: 13px; color: var(--text-2); }
.quality li b { color: var(--text); white-space: nowrap; }
.quality li.bad b { color: var(--warn); }

.budget, .access { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.budget-bar { height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.budget-bar i { display: block; height: 100%; width: 0; background: var(--green); border-radius: 999px; transition: width .3s; }
.budget-bar i.high { background: #e3a008; }
.budget-bar i.full { background: var(--danger); }
.budget p { margin: 0; font-size: 13.5px; color: var(--text-2); }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-form label { font-size: 12.5px; font-weight: 600; color: var(--muted); width: 100%; }
.inline-form input {
  flex: 1; min-width: 140px; font: inherit; font-size: 15px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
}
.inline-form input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-50); }
.access-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.access-row code { white-space: normal; word-break: break-all; font-size: 12.5px; }
.hint-text { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

@media (max-width: 1180px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .grid-2, .grid-2.wide-left { grid-template-columns: 1fr; }
  .admin { padding: 14px 12px 30px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #topActions .btn:not(#logout) { display: none; }
}

/* ===== Admin : onglets et apprentissage ===== */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: -4px; }
.tab {
  border: none; background: none; cursor: pointer; padding: 10px 14px; font-weight: 700; font-size: 14px; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-count { font-size: 11px; background: var(--blue-50); color: var(--blue); border-radius: 999px; padding: 1px 8px; }
.tab-panel { display: flex; flex-direction: column; gap: 18px; }
.learn-intro .panel-head p { max-width: 860px; line-height: 1.55; }
.learn-form { display: grid; grid-template-columns: 160px minmax(0, 1fr) 140px 170px; gap: 12px 14px; padding: 16px 18px 18px; align-items: end; }
.learn-form .field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.learn-form label { font-size: 12px; font-weight: 700; color: var(--text-2); }
.learn-form .req { color: var(--danger); }
.learn-form .opt { font-weight: 500; color: var(--muted); }
.learn-form input, .search, .import-body textarea {
  font: inherit; font-size: 14.5px; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--text); width: 100%;
}
.learn-form input:focus, .search:focus, .import-body textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-50); background: var(--surface); }
.learn-form .form-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.learn-form .login-error { grid-column: 1 / -1; }
.btn-primary { background: var(--blue); color: #fff; border: 1px solid var(--blue); }
.btn-primary:hover { background: var(--blue-600); }
.search { max-width: 320px; }
.learn-code { font-family: var(--mono); font-weight: 700; color: var(--blue); white-space: nowrap; }
.import-panel summary { cursor: pointer; padding: 14px 18px; font-size: 14px; font-weight: 700; color: var(--text-2); }
.import-body { padding: 0 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.import-body textarea { font-family: var(--mono); font-size: 13px; resize: vertical; }
.import-body .form-actions { display: flex; align-items: center; gap: 12px; }
.editing td { background: var(--blue-50) !important; }
@media (max-width: 900px) {
  .learn-form { grid-template-columns: 1fr 1fr; }
  .learn-form .field.grow { grid-column: 1 / -1; }
  .search { max-width: none; }
}

/* ===== Bandeau d'installation (téléphone) ===== */
.install-banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 15;
  display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px;
  box-shadow: var(--shadow-lg); animation: rise .3s ease-out;
}
.install-icon { width: 44px; height: 44px; border-radius: 11px; border: 1px solid var(--line); }
.install-text { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text-2); line-height: 1.4; }
.install-text b { color: var(--text); font-size: 14px; }
.install-text .ios-share { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; background: var(--blue-50); color: var(--blue); vertical-align: -4px; }
.install-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }

/* ===== Maintenance ===== */
.maint-banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; font-size: 13.5px; font-weight: 600;
  background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.maintenance-card {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius);
  background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); color: var(--text);
}
.maintenance-card .mt-icon { font-size: 22px; line-height: 1; }
.maintenance-card b { color: var(--warn); }
.maintenance-card p { margin: 4px 0 0; color: var(--text-2); line-height: 1.6; }

/* ===== Admin : alertes et services ===== */
.alerts { display: flex; flex-direction: column; gap: 12px; }
.alert-card {
  background: color-mix(in srgb, var(--danger) 7%, var(--surface)); border: 1.5px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: 16px; padding: 14px 18px; display: flex; flex-direction: column; gap: 6px;
}
.alert-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 15px; color: var(--danger); }
.alert-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse-dot 1s infinite; }
.alert-since { font-size: 12px; color: var(--muted); font-weight: 500; }
.alert-impact, .alert-help { margin: 0; font-size: 13.5px; color: var(--text-2); line-height: 1.5; }
.alert-help { color: var(--text); font-weight: 600; }
.alert-card details summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.alert-detail { display: block; margin-top: 6px; white-space: pre-wrap; word-break: break-word; font-size: 11.5px; }
.services { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 14px 18px; }
.svc { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); }
.svc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; }
.svc-state { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.svc.ok .svc-state { background: var(--green-50); color: var(--green-700); }
.svc.ko { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.svc.ko .svc-state { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.svc.unknown .svc-state { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.svc p { margin: 0; font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.svc-err { color: var(--danger) !important; word-break: break-word; }
.svc-meter { height: 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.svc-meter i { display: block; height: 100%; background: var(--blue); }
.svc-history { padding: 0 18px 14px; }
.svc-history summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--text-2); padding: 4px 0; }
.svc-history ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.h-ok { color: var(--green-700); font-weight: 700; }
.h-ko { color: var(--danger); font-weight: 700; }
@media (max-width: 900px) { .services { grid-template-columns: 1fr; } }

/* ===== Plafond par utilisateur ===== */
.cap-cell { min-width: 150px; display: flex; flex-direction: column; gap: 3px; }
.cap-line { font-size: 13px; white-space: nowrap; }
.cap-bar { height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.cap-bar i { display: block; height: 100%; background: var(--green); }
.cap-cell.high .cap-bar i { background: #e3a008; }
.cap-cell.reached .cap-bar i { background: var(--danger); }
.cap-cell.reached .dev-meta { color: var(--danger); font-weight: 700; }
.select {
  font: inherit; font-size: 14px; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
}

/* ===== Admin : utilisateurs ===== */
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.user-form { grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line-2); background: var(--surface-2); }
.pass-row { display: flex; gap: 6px; }
.pass-row input { font-family: var(--mono); }
.sessions { display: flex; flex-direction: column; gap: 4px; min-width: 210px; }
.session { display: flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.dot-on, .dot-off { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot-on { background: var(--green); box-shadow: 0 0 0 3px var(--green-100); }
.dot-off { background: var(--line); }
.dev-meta.last-q { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 900px) { .user-form { grid-template-columns: 1fr 1fr; } }

/* ===== App : menu utilisateur et historique ===== */
.user-menu { position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800;
  background: var(--blue-50); color: var(--blue);
}
.user-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 12; min-width: 220px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px;
}
.user-pop .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; font-size: 13px; }
.user-pop .who b { display: block; font-size: 14px; }
.user-pop .who span { color: var(--muted); }
.user-pop button {
  width: 100%; text-align: left; border: none; background: none; cursor: pointer; padding: 9px 10px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--text-2);
}
.user-pop button:hover { background: var(--surface-2); color: var(--text); }
.user-pop .cap-mini { padding: 6px 10px 8px; font-size: 12px; color: var(--muted); }
.side-tabs { display: flex; gap: 4px; padding: 10px 10px 0; border-bottom: 1px solid var(--line-2); }
.side-tab {
  border: none; background: none; cursor: pointer; padding: 8px 10px; font-weight: 700; font-size: 13px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.side-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.history-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.history-list li.h-item { padding: 9px 10px; border-radius: 12px; display: flex; flex-direction: column; gap: 3px; }
.history-list li.h-item:hover { background: var(--surface-2); }
.h-q { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-a { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; }
.h-when { font-size: 11.5px; color: var(--muted); }
.history-list .empty { color: var(--muted); font-size: 13px; padding: 16px 10px; text-align: center; line-height: 1.6; }
.history-modal-list { max-height: 60vh; overflow-y: auto; width: 100%; text-align: left; }

/* ===== En-tête compact (nom long « Assistant IA du Personnel ») ===== */
.brand-title { min-width: 0; }
.brand-title h1 { white-space: nowrap; font-size: 19px; }
.brand-title p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { flex-wrap: nowrap; }
.top-actions .btn { white-space: nowrap; }
@media (max-width: 1320px) {
  .status-pill { display: none; }
}
@media (max-width: 1180px) {
  .brand-title p { display: none; }
  .top-actions .lbl, #userName, .switch-label { display: none; }
  .top-actions .btn { padding: 8px 10px; }
}
@media (max-width: 900px) {
  .brand-title h1 { font-size: 16px; }
  .brand-divider { display: none; }
}
@media (max-width: 520px) {
  .brand-title h1 { font-size: 0; }
  .brand-title h1 .ia-badge { font-size: 11px; }
  .brand-title h1::before { content: "Assistant IA"; font-size: 15px; }
}

/* ===== Sélecteur segmenté (NGAP / Dispositifs) ===== */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg-btn {
  border: none; background: none; cursor: pointer; padding: 7px 12px; border-radius: 9px;
  font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap;
}
.seg-btn.active { background: var(--surface); color: var(--blue); box-shadow: var(--shadow-sm); }
.seg.small .seg-btn { padding: 5px 10px; font-size: 12px; }
.learn-form .base-field { grid-column: 1 / -1; }
.import-base { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tag.base-ngap { background: var(--blue-50); color: var(--blue); border-color: transparent; }
.tag.base-dispositif { background: var(--green-50); color: var(--green-700); border-color: transparent; }

/* ===== Choix de la base : Actes NGAP / Dispositifs médicaux ===== */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 auto 18px; max-width: 640px; text-align: left; }
.mode-card {
  display: flex; align-items: center; gap: 14px; cursor: pointer; padding: 16px 18px; border-radius: 16px;
  background: var(--surface); border: 2px solid var(--line); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.mode-card:hover { border-color: var(--blue); transform: translateY(-1px); box-shadow: var(--shadow); }
.mode-card.active { border-color: var(--blue); background: var(--blue-50); box-shadow: 0 0 0 4px var(--blue-50); }
.mode-card.pulse { animation: mode-pulse 1s 2; }
@keyframes mode-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--blue) 25%, transparent); } }
.mode-icon { font-size: 30px; line-height: 1; }
.mode-text { display: flex; flex-direction: column; gap: 3px; }
.mode-text b { font-size: 15px; }
.mode-text small { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.cat-icon { font-size: 18px; }
.mode-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.mode-bar-label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.mode-bar .seg.pulse { animation: mode-pulse 1s 2; border-color: var(--blue); }
.mode-divider { align-self: center; font-size: 12px; font-weight: 700; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }
.ap-yes { color: var(--warn); font-weight: 700; }
.ap-no { color: var(--green-700); font-weight: 700; }
@media (max-width: 760px) {
  .modes { grid-template-columns: 1fr; }
  .mode-bar-label { display: none; }
  .mode-bar .seg { width: 100%; }
  .mode-bar .seg-btn { flex: 1; padding: 7px 6px; font-size: 12.5px; }
}
.s-type.dm { background: var(--green-50); color: var(--green-700); }
.learn-form .base-field .seg { width: fit-content; }

/* Mode fun / mode pro */
.fun-icon { font-size: 15px; line-height: 1; }
body:not(.tone-pro) .only-pro, body.tone-pro .only-fun { display: none !important; }
body.tone-pro .wake .z { display: none; }
.fun-switch input:not(:checked) + .track { background: var(--blue); }
/* Téléphone : l'interrupteur fun/pro devient une simple icône à toucher (😄 / 👔) */
.top-actions > * { flex-shrink: 0; }
@media (max-width: 520px) {
  .brand-title { display: none; }
  .top-actions { gap: 6px; }
  .fun-switch .track { display: none; }
  .fun-icon { font-size: 22px; padding: 2px; }
  .voice-select select { max-width: 86px; }
}

/* Admin : réponse reçue par l'agent, sous la question */
.recent-row { cursor: pointer; }
.recent-row td:first-child::before { content: "▸ "; color: var(--muted); }
.recent-row.open td:first-child::before { content: "▾ "; }
.recent-row.open td { background: var(--surface-2); }
.answer-row td { background: var(--surface-2); padding: 4px 18px 18px; }
.ans-voice { margin: 6px 0 10px; font-size: 15px; color: var(--text-2); }
.ans-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; line-height: 1.6; font-size: 14px; max-width: 900px; white-space: normal; }
