/* =========================================================
   Plume — design tokens
   Lagune (teal) pour l'action, ambre pour le raisonnement.
   ========================================================= */
:root {
  --bg: #F3F5F9;
  --surface: #FFFFFF;
  --surface-2: #EAEDF4;
  --surface-3: #DFE3EC;
  --ink: #1C2033;
  --ink-2: #565C73;
  --ink-3: #8A90A6;
  --line: #DBDFE9;
  --accent: #0F8B7E;
  --accent-hover: #0B7468;
  --accent-soft: #DCF1EE;
  --accent-ink: #FFFFFF;
  --think: #A86A12;
  --think-soft: #FBF2E0;
  --danger: #C2413A;
  --danger-soft: #FBE7E5;
  --user-bubble: #E3E8F3;
  --shadow-lg: 0 18px 50px -12px rgba(28, 32, 51, .22);
  --shadow-sm: 0 1px 2px rgba(28, 32, 51, .06), 0 4px 14px -6px rgba(28, 32, 51, .12);

  --font-ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --sidebar-w: 288px;
  --thread-w: 780px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 22px;

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161925; --surface: #1E2232; --surface-2: #272C3F; --surface-3: #31374D;
    --ink: #E8EAF2; --ink-2: #A3A9C0; --ink-3: #737A93; --line: #31374C;
    --accent: #3CC4B3; --accent-hover: #5AD3C3; --accent-soft: #173D3B; --accent-ink: #0C2421;
    --think: #E6B65A; --think-soft: #2C2718; --danger: #EE6E66; --danger-soft: #3A2124;
    --user-bubble: #2A3046;
    --shadow-lg: 0 18px 50px -12px rgba(0,0,0,.55); --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px -6px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161925; --surface: #1E2232; --surface-2: #272C3F; --surface-3: #31374D;
  --ink: #E8EAF2; --ink-2: #A3A9C0; --ink-3: #737A93; --line: #31374C;
  --accent: #3CC4B3; --accent-hover: #5AD3C3; --accent-soft: #173D3B; --accent-ink: #0C2421;
  --think: #E6B65A; --think-soft: #2C2718; --danger: #EE6E66; --danger-soft: #3A2124;
  --user-bubble: #2A3046;
  --shadow-lg: 0 18px 50px -12px rgba(0,0,0,.55); --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px -6px rgba(0,0,0,.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: inherit; }
html, body { height: 100%; margin: 0; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  background: var(--bg); color: var(--ink);
  font: 15.5px/1.6 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
kbd { font: 500 11px var(--font-ui); color: var(--ink-3); background: var(--surface-2); border-radius: 5px; padding: 2px 6px; }
[hidden] { display: none !important; }

/* ================= Layout ================= */
.app { display: flex; height: 100%; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 12px 12px;
  background: var(--surface); border-right: 1px solid var(--line);
  transition: margin-left .25s ease, transform .25s ease;
}
.app.side-collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }

.side-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 6px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; stroke-width: 2.1; }
.brand-name { font: 700 21px/1 var(--font-display); letter-spacing: -.02em; }

.new-chat {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: var(--r-md);
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
  transition: background .15s;
}
.new-chat:hover { background: var(--accent-hover); }
.new-chat span { flex: 1; text-align: left; white-space: nowrap; }
.new-chat kbd { background: rgba(255,255,255,.18); color: inherit; opacity: .85; }

.side-search { display: flex; align-items: center; gap: 8px; padding: 0 11px; height: 38px; border-radius: var(--r-md); background: var(--surface-2); color: var(--ink-3); }
.side-search svg { width: 16px; height: 16px; }
.side-search input { flex: 1; border: 0; background: none; outline: none; color: var(--ink); min-width: 0; }
.side-search input::placeholder { color: var(--ink-3); }

.chat-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; }
.group-title { font-size: 12.5px; font-weight: 600; color: var(--ink-3); padding: 14px 10px 6px; }
.chat-item {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer;
  color: var(--ink-2); font-size: 14.5px;
}
.chat-item:hover { background: var(--surface-2); color: var(--ink); }
.chat-item.active { background: var(--accent-soft); color: var(--ink); }
.chat-item .t { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-item .pin-dot { width: 14px; height: 14px; color: var(--accent); }
.chat-item .acts { display: none; gap: 2px; }
.chat-item:hover .acts, .chat-item:focus-within .acts { display: flex; }
.chat-item .acts button { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; color: var(--ink-3); }
.chat-item .acts button:hover { background: var(--surface-3); color: var(--ink); }
.chat-item .acts svg { width: 15px; height: 15px; }
.chat-item input { flex: 1; min-width: 0; border: 1px solid var(--accent); border-radius: 6px; padding: 2px 6px; background: var(--surface); outline: none; }
.list-empty { color: var(--ink-3); font-size: 14px; padding: 18px 10px; }

.side-foot { display: flex; gap: 6px; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); }
.fire-btn { flex: 1; display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; }
.fire-btn:hover { background: var(--danger-soft); color: var(--danger); }
.privacy-note { display: flex; align-items: center; gap: 6px; margin: 0; padding: 0 10px; font-size: 12.5px; color: var(--ink-3); }
.privacy-note svg { width: 13px; height: 13px; }

.icon-btn { width: 36px; height: 36px; border-radius: var(--r-sm); display: grid; place-items: center; color: var(--ink-2); flex-shrink: 0; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.only-mobile { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }

/* ================= Topbar & modèle ================= */
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; position: relative; z-index: 20; }
.top-actions { margin-left: auto; display: flex; }
.model-picker { position: relative; }
.model-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px 7px 14px; border-radius: var(--r-md);
  font: 600 16px var(--font-display); letter-spacing: -.01em;
}
.model-btn:hover, .model-btn[aria-expanded="true"] { background: var(--surface-2); }
.model-btn .chev { width: 16px; height: 16px; color: var(--ink-3); transition: transform .2s; }
.model-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.model-btn-badges { display: flex; gap: 4px; }

.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 999px; font: 600 11.5px var(--font-ui); letter-spacing: 0; }
.badge.reasoning { background: var(--think-soft); color: var(--think); }
.badge.vision { background: var(--accent-soft); color: var(--accent); }
.badge.search { background: var(--surface-3); color: var(--ink-2); }
.badge.fast { background: var(--surface-2); color: var(--ink-2); }

.popover {
  position: absolute; top: calc(100% + 6px); left: 0; width: min(420px, calc(100vw - 28px));
  max-height: min(70vh, 560px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg);
  animation: pop .16s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.pop-search { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--ink-3); }
.pop-search svg { width: 16px; height: 16px; }
.pop-search input { flex: 1; border: 0; outline: none; background: none; color: var(--ink); }
.pop-list { overflow-y: auto; padding: 6px; }
.pop-group { font-size: 12.5px; font-weight: 600; color: var(--ink-3); padding: 10px 10px 4px; }
.model-opt { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 9px 10px; border-radius: 10px; }
.model-opt:hover, .model-opt.kbd { background: var(--surface-2); }
.model-opt.selected { background: var(--accent-soft); }
.model-opt .mo-main { flex: 1; min-width: 0; }
.model-opt .mo-name { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.model-opt .mo-id { font: 12px var(--font-mono); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-opt .mo-ctx { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.model-opt .mo-check { width: 18px; height: 18px; color: var(--accent); visibility: hidden; }
.model-opt.selected .mo-check { visibility: visible; }

.banner { margin: 0 auto 6px; max-width: var(--thread-w); width: calc(100% - 28px); padding: 10px 14px; border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger); font-size: 14px; }

/* ================= Fil de discussion ================= */
.thread { flex: 1; overflow-y: auto; scroll-behavior: auto; padding: 0 16px 24px; }
.messages { max-width: var(--thread-w); margin: 0 auto; display: flex; flex-direction: column; gap: 28px; padding-top: 12px; }

.welcome { max-width: var(--thread-w); margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 6vh 4px 2vh; }
.wordmark {
  margin: 0; font: 700 clamp(64px, 12vw, 148px)/.86 var(--font-display);
  letter-spacing: -.055em; font-variation-settings: "opsz" 96;
  background: linear-gradient(100deg, var(--ink) 30%, var(--accent) 120%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.welcome-sub { margin: 22px 0 34px; max-width: 46ch; font-size: 18px; line-height: 1.5; color: var(--ink-2); }
.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.suggestion {
  text-align: left; padding: 14px 16px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface);
  transition: border-color .15s, background .15s;
}
.suggestion:hover { border-color: var(--accent); }
.suggestion strong { display: block; font-weight: 600; }
.suggestion span { display: block; color: var(--ink-3); font-size: 14px; margin-top: 2px; }
.app.has-messages .welcome { display: none; }

/* message utilisateur */
.msg.user { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.msg.user .bubble { max-width: min(82%, 640px); background: var(--user-bubble); padding: 11px 16px; border-radius: 20px 20px 6px 20px; overflow-wrap: anywhere; }
.msg.user .bubble .md > :first-child { margin-top: 0; } .msg.user .bubble .md > :last-child { margin-bottom: 0; }
.msg.user .imgs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.msg.user .imgs img { width: 120px; height: 120px; object-fit: cover; border-radius: 12px; cursor: zoom-in; }
.msg.user .edit-box { width: min(100%, 640px); background: var(--surface); border: 1px solid var(--accent); border-radius: 16px; padding: 10px; }
.msg.user .edit-box textarea { width: 100%; border: 0; outline: none; background: none; resize: vertical; min-height: 70px; }

/* message assistant */
.msg.assistant { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 14px; }
.avatar { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; margin-top: 2px; }
.avatar svg { width: 16px; height: 16px; stroke-width: 2.1; }
.msg.assistant.streaming .avatar { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(.88); opacity: .75; } }
.model-tag { font-size: 13px; color: var(--ink-3); margin-bottom: 4px; font-weight: 500; }

/* bloc de raisonnement — l'élément signature */
.think { margin: 2px 0 14px; border-left: 2px solid var(--think); padding-left: 14px; }
.think summary {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--think); font-weight: 600; font-size: 14px; padding: 3px 0;
}
.think summary::-webkit-details-marker { display: none; }
.think summary svg { width: 16px; height: 16px; }
.think summary .chev { width: 14px; height: 14px; transition: transform .2s; }
.think[open] summary .chev { transform: rotate(180deg); }
.think.live { border-image: linear-gradient(var(--think), transparent) 1; }
.think.live summary .spark { animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.think-body { color: var(--ink-2); font-size: 14.5px; line-height: 1.6; margin-top: 6px; max-height: 420px; overflow-y: auto; }
.think-body.md p { margin: .5em 0; }

.content { overflow-wrap: anywhere; }
.cursor::after { content: ""; display: inline-block; width: 8px; height: 1.05em; margin-left: 2px; vertical-align: -0.15em; background: var(--accent); border-radius: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: dot 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.source { display: inline-flex; align-items: center; gap: 6px; max-width: 260px; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 13px; text-decoration: none; }
.source:hover { color: var(--ink); background: var(--surface-3); }
.source img { width: 14px; height: 14px; border-radius: 3px; }
.source span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.msg-error { margin-top: 10px; padding: 10px 14px; border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.stopped-note { margin-top: 8px; font-size: 13px; color: var(--ink-3); font-style: italic; }

.actions { display: flex; align-items: center; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg:hover .actions, .msg:focus-within .actions, .msg.last .actions { opacity: 1; }
.actions button { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--ink-3); }
.actions button:hover { background: var(--surface-2); color: var(--ink); }
.actions svg { width: 16px; height: 16px; }
.stats { margin-left: 8px; font-size: 12.5px; color: var(--ink-3); display: inline-flex; gap: 12px; }

/* ================= Markdown ================= */
.md { line-height: 1.7; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: .75em 0; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--font-display); line-height: 1.25; letter-spacing: -.015em; margin: 1.4em 0 .5em; }
.md h1 { font-size: 1.55em; } .md h2 { font-size: 1.3em; } .md h3 { font-size: 1.12em; } .md h4 { font-size: 1em; }
.md ul, .md ol { padding-left: 1.4em; margin: .6em 0; }
.md li { margin: .3em 0; }
.md li::marker { color: var(--ink-3); }
.md a { color: var(--accent); text-underline-offset: 3px; }
.md blockquote { margin: 1em 0; padding: 2px 16px; border-left: 3px solid var(--line); color: var(--ink-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.md img { max-width: 100%; border-radius: var(--r-md); }
.md :not(pre) > code { font: .88em var(--font-mono); background: var(--surface-2); padding: .15em .4em; border-radius: 6px; }
.md .table-wrap { overflow-x: auto; margin: 1em 0; border: 1px solid var(--line); border-radius: var(--r-md); }
.md table { border-collapse: collapse; width: 100%; font-size: .94em; }
.md th, .md td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.md th { background: var(--surface-2); font-weight: 600; }
.md tr:last-child td { border-bottom: 0; }
.md .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

.code-block { margin: 1em 0; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; font-size: 12.5px; color: var(--ink-3); background: var(--surface-3); }
.code-head button { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 6px; color: var(--ink-2); font-size: 12.5px; }
.code-head button:hover { background: var(--surface-2); color: var(--ink); }
.code-head svg { width: 14px; height: 14px; }
.code-block pre { margin: 0; padding: 14px 16px; overflow-x: auto; font: 13.5px/1.6 var(--font-mono); }
.code-block code { font-family: inherit; background: none; padding: 0; }

/* coloration syntaxique liée au thème */
.hljs-comment, .hljs-quote { color: var(--ink-3); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-name { color: #8250DF; }
.hljs-string, .hljs-attr, .hljs-template-tag, .hljs-addition { color: #0A7F5A; }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: #B35C00; }
.hljs-title, .hljs-section, .hljs-function .hljs-title { color: #0B62C4; }
.hljs-type, .hljs-class .hljs-title, .hljs-variable, .hljs-params { color: #A1366F; }
.hljs-meta, .hljs-regexp, .hljs-link { color: #116E8A; }
.hljs-deletion { color: var(--danger); }
:root[data-theme="dark"] .hljs-keyword, :root[data-theme="dark"] .hljs-selector-tag, :root[data-theme="dark"] .hljs-built_in, :root[data-theme="dark"] .hljs-name { color: #C4A1FF; }
:root[data-theme="dark"] .hljs-string, :root[data-theme="dark"] .hljs-attr, :root[data-theme="dark"] .hljs-addition { color: #7EE0B5; }
:root[data-theme="dark"] .hljs-number, :root[data-theme="dark"] .hljs-literal, :root[data-theme="dark"] .hljs-symbol { color: #F5B26B; }
:root[data-theme="dark"] .hljs-title, :root[data-theme="dark"] .hljs-section { color: #79B8FF; }
:root[data-theme="dark"] .hljs-type, :root[data-theme="dark"] .hljs-variable, :root[data-theme="dark"] .hljs-params { color: #F38BC0; }
:root[data-theme="dark"] .hljs-meta, :root[data-theme="dark"] .hljs-regexp { color: #6CD3EA; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hljs-keyword, :root:not([data-theme="light"]) .hljs-built_in, :root:not([data-theme="light"]) .hljs-name { color: #C4A1FF; }
  :root:not([data-theme="light"]) .hljs-string, :root:not([data-theme="light"]) .hljs-attr { color: #7EE0B5; }
  :root:not([data-theme="light"]) .hljs-number, :root:not([data-theme="light"]) .hljs-literal { color: #F5B26B; }
  :root:not([data-theme="light"]) .hljs-title, :root:not([data-theme="light"]) .hljs-section { color: #79B8FF; }
  :root:not([data-theme="light"]) .hljs-type, :root:not([data-theme="light"]) .hljs-variable, :root:not([data-theme="light"]) .hljs-params { color: #F38BC0; }
  :root:not([data-theme="light"]) .hljs-meta, :root:not([data-theme="light"]) .hljs-regexp { color: #6CD3EA; }
}

/* ================= Zone de saisie ================= */
.composer-wrap { padding: 0 16px 14px; }
.composer {
  max-width: var(--thread-w); margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: 10px 10px 8px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--accent); }
.composer.drag { border-style: dashed; border-color: var(--accent); background: var(--accent-soft); }
.composer textarea { width: 100%; border: 0; outline: none; background: none; resize: none; max-height: 38vh; padding: 6px 0 4px; font-size: 16px; line-height: 1.5; }
.composer textarea::placeholder { color: var(--ink-3); }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-left: -6px; }
.tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.tool-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--ink-2); }
.tool-btn:hover { background: var(--surface-2); color: var(--ink); }
.tool-btn.recording { background: var(--danger-soft); color: var(--danger); animation: breathe 1.2s infinite; }
.tool-btn.busy { opacity: .5; pointer-events: none; }
.pill-toggle { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); font-size: 14px; font-weight: 500; }
.pill-toggle svg { width: 16px; height: 16px; }
.pill-toggle:hover { color: var(--ink); border-color: var(--ink-3); }
.pill-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.send-btn { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); transition: background .15s, opacity .15s; }
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: .35; cursor: default; }
.send-btn svg { stroke-width: 2.3; }
.send-btn.stop { background: var(--ink); color: var(--surface); }
.attachments { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 0 8px; }
.thumb { position: relative; width: 64px; height: 64px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.thumb button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: var(--surface); display: grid; place-items: center; }
.thumb button svg { width: 12px; height: 12px; stroke-width: 2.6; }
.disclaimer { text-align: center; font-size: 12.5px; color: var(--ink-3); margin: 8px 0 0; }

.to-bottom { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); width: 38px; height: 38px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); display: grid; place-items: center; color: var(--ink-2); z-index: 5; }

/* ================= Modales ================= */
.modal { border: 0; padding: 0; background: transparent; max-width: calc(100vw - 24px); color: var(--ink); }
.modal::backdrop { background: rgba(18, 20, 32, .45); backdrop-filter: blur(3px); }
.modal[open] { animation: pop .18s ease-out; }
.modal-card { width: 560px; max-width: 100%; max-height: 86vh; overflow-y: auto; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 22px 24px 24px; }
.modal-card.small { width: 400px; text-align: center; }
.modal-card h2 { margin: 0; font: 700 22px/1.2 var(--font-display); letter-spacing: -.02em; }
.modal-card.small h2 { margin-top: 12px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-body { display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field.two label { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; }
.field-label output { color: var(--ink-3); font-weight: 500; }
.field textarea, .field select, .text-input { width: 100%; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); padding: 10px 12px; outline: none; resize: vertical; }
.field textarea:focus, .field select:focus, .text-input:focus { border-color: var(--accent); }
input[type="range"] { accent-color: var(--accent); width: 100%; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 11px; align-self: flex-start; }
.segmented button { padding: 6px 14px; border-radius: 8px; font-weight: 500; font-size: 14px; color: var(--ink-2); }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 14.5px; }
.switch { appearance: none; width: 40px; height: 24px; border-radius: 999px; background: var(--surface-3); position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row.end { justify-content: center; margin-top: 18px; }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 11px; font-weight: 600; font-size: 14.5px; }
.btn svg { width: 16px; height: 16px; }
.btn.ghost { border: 1px solid var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.muted { color: var(--ink-2); margin: 8px 0 0; }
.fire-art { width: 64px; height: 64px; border-radius: 20px; margin: 4px auto 0; background: var(--danger-soft); color: var(--danger); display: grid; place-items: center; }
.fire-art svg { width: 32px; height: 32px; }
.fire-art.lock { background: var(--accent-soft); color: var(--accent); }
.text-input { margin-top: 16px; }

/* Animation du bouton d'effacement */
.flame-overlay { position: fixed; inset: 0; z-index: 100; pointer-events: none; background: radial-gradient(circle at 50% 110%, #FFB347 0%, #F0633A 35%, rgba(194,65,58,0) 70%); animation: burn .9s ease-out forwards; }
@keyframes burn { 0% { opacity: 0; transform: translateY(40%); } 40% { opacity: .95; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-30%); } }

/* Toasts */
.toasts { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow-lg); animation: pop .2s ease-out; max-width: calc(100vw - 32px); }
.toast.err { background: var(--danger); color: #fff; }

/* Visionneuse d'image */
.lightbox { position: fixed; inset: 0; z-index: 150; background: rgba(10,12,20,.85); display: grid; place-items: center; cursor: zoom-out; padding: 24px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; }

/* ================= Responsive ================= */
@media (max-width: 860px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; transform: translateX(-100%); margin-left: 0 !important; box-shadow: var(--shadow-lg); padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .app.side-open .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 55; background: rgba(18,20,32,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .app.side-open .scrim { opacity: 1; pointer-events: auto; }
  .only-mobile { display: grid; }
  .new-chat kbd { display: none; }
  .suggestions { grid-template-columns: 1fr; }
  .suggestion:nth-child(n+3) { display: none; }
  .welcome-sub { font-size: 16.5px; }
  .model-btn-badges { display: none; }
  .msg.assistant { grid-template-columns: minmax(0, 1fr); }
  .msg.assistant .avatar { display: none; }
  .actions { opacity: 1; }
  .field.two { grid-template-columns: 1fr; }
  .pill-toggle span { display: none; }
  .pill-toggle { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
