:root {
  --bg: #0b0f19;
  --bg2: #101624;
  --bg3: #161d2f;
  --panel: #131a2a;
  --border: #232d45;
  --border2: #2e3a58;
  --text: #e5eaf4;
  --muted: #8b95ad;
  --muted2: #5d6a85;
  --accent: #6366f1;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 12px;
  --red: #ef4444;
  --orange: #f97316;
  --amber: #d97706;
  --green: #22c55e;
  --teal: #14b8a6;
  --cyan: #06b6d4;
  --blue: #3b82f6;
  --indigo: #6366f1;
  --violet: #8b5cf6;
  --pink: #ec4899;
}

* { box-sizing: border-box; }
html, body { height: 100%; overscroll-behavior-y: none; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
textarea, input, select { font: inherit; color: inherit; }

.btn {
  border: 1px solid var(--border2);
  background: var(--bg3);
  border-radius: 9px;
  padding: 8px 14px;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--border); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #7475f3; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--danger); color: #fca5a5; }
.btn.danger:hover { background: rgba(239,68,68,.12); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.full { width: 100%; }

.icon-btn {
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 6px 9px;
  color: var(--muted);
  font-size: 16px;
}
.icon-btn:hover { background: var(--bg3); color: var(--text); }

.login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(60% 50% at 20% 10%, rgba(99,102,241,.18), transparent),
    radial-gradient(50% 40% at 85% 85%, rgba(139,92,246,.14), transparent),
    var(--bg);
  z-index: 50;
}
.login-card {
  width: min(380px, 90vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 34px 30px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.login-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background:
    linear-gradient(135deg, var(--violet) 0 50%, var(--blue) 50% 75%, var(--green) 75% 90%, var(--orange) 90%);
  opacity: .9;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.login-card input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 12px;
  outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-key {
  margin-bottom: 12px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.login-key.ok { border-color: var(--green); color: #86efac; }
.login-error { color: #fca5a5; font-size: 13px; margin-top: 10px; }

.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 290px;
  min-width: 290px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  gap: 8px;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  cursor: pointer;
  flex: none;
  background: var(--bg3);
}
.user-avatar:hover { border-color: var(--accent); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; letter-spacing: .2px; flex: 1; min-width: 0; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #555;
  flex: none;
}
.conn-dot.on { background: var(--ok); box-shadow: 0 0 8px rgba(34,197,94,.7); }
.conn-dot.off { background: var(--danger); box-shadow: 0 0 8px rgba(239,68,68,.6); }

.filters {
  display: flex;
  gap: 4px;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
}
.filters button {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 5px 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.filters button:hover { color: var(--text); background: var(--bg3); }
.filters button.active { color: var(--text); background: var(--bg3); border-color: var(--border2); font-weight: 600; }
#btn-archived { flex: 0 0 36px; font-size: 13px; }
#btn-archived.active { color: var(--text); background: var(--bg3); border-color: var(--border2); }

.tree { flex: 1; overflow-y: auto; padding: 10px 10px 16px; }
.mother-block { margin-bottom: 12px; }
.mother-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 9px;
  user-select: none;
}
.mother-row:hover { background: var(--bg3); }
.mother-name { font-weight: 650; font-size: 14.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.mother-name:hover { color: var(--accent); }
.mother-count { font-size: 11.5px; color: var(--muted); background: var(--bg3); border-radius: 20px; padding: 1px 8px; }
.mother-menu { opacity: 0; }
.mother-row:hover .mother-menu { opacity: 1; }
.mother-bilan { opacity: 0; font-size: 13px; }
.mother-row:hover .mother-bilan { opacity: 1; }
.child-list { margin: 2px 0 0 14px; }
.child-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  border-radius: 9px;
  border-left: 2px solid transparent;
  cursor: pointer;
  color: var(--muted);
}
.child-row:hover { background: var(--bg3); color: var(--text); }
.child-row.active {
  background: var(--bg3);
  color: var(--text);
  border-left-color: var(--child-color, var(--accent));
  font-weight: 600;
}
.child-row.archived { opacity: .55; }
.child-row.done .child-name { text-decoration: none; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status-dot.none { visibility: hidden; }
.status-dot.orange { background: var(--orange); box-shadow: 0 0 7px rgba(249,115,22,.65); }
.status-dot.green { background: var(--ok); animation: pulse 1.2s infinite; }
.status-dot.blue { background: var(--blue); box-shadow: 0 0 6px rgba(59,130,246,.5); }

/* Mode Hors-connexion / Déconnecté */
.offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.22), rgba(185, 28, 28, 0.28));
  border-bottom: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
  z-index: 25;
  transition: all 0.3s ease;
}

.offline-banner.warning {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(180, 83, 9, 0.28));
  border-bottom-color: rgba(245, 158, 11, 0.45);
  color: #fcd34d;
}

.offline-banner .off-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.offline-banner .off-text {
  flex: 1;
}

.offline-banner .off-retry-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 4px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.offline-banner .off-retry-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Griserie globale des éléments de chat, prompt, arbre et projets en mode hors connexion */
body.is-offline #chat,
body.is-offline #prompt-zone,
body.is-offline .promptbar,
body.is-offline .msg,
body.is-offline .home-grid,
body.is-offline .home-list,
body.is-offline #tree {
  filter: grayscale(0.85) opacity(0.65);
  transition: filter 0.3s ease, opacity 0.3s ease;
}

body.is-offline #prompt-input,
body.is-offline #btn-send,
body.is-offline #btn-new-project,
body.is-offline #btn-new-mother,
body.is-offline .snippet-chip {
  pointer-events: none !important;
  cursor: not-allowed !important;
}

#offline-banner {
  filter: none !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.perm-banner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(249, 115, 22, .14);
  border-bottom: 1px solid rgba(249, 115, 22, .45);
  /* Plusieurs questions peuvent être longues : on borne la hauteur et on rend
     le bandeau défilable pour toujours pouvoir atteindre « Répondre ». */
  max-height: min(60vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.perm-banner::-webkit-scrollbar { width: 7px; }
.perm-banner::-webkit-scrollbar-thumb { background: rgba(249, 115, 22, .45); border-radius: 7px; }
/* La barre d'actions reste collée en bas du bandeau : « Répondre » accessible
   même quand on fait défiler plusieurs questions. */
.perm-banner .perm-actions {
  position: sticky;
  bottom: -12px;
  margin: 0 -16px -12px;
  padding: 10px 16px 12px;
  background: linear-gradient(rgba(249, 115, 22, .14), rgba(249, 115, 22, .14)), var(--bg2);
  border-top: 1px solid rgba(249, 115, 22, .35);
}
.perm-label { font-size: 14px; color: #fdba74; line-height: 1.45; }
.perm-meta {
  color: #e2e8f0;
  background: rgba(0, 0, 0, .35);
  border: 1px solid rgba(249, 115, 22, .3);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  margin-top: 7px;
  word-break: break-word;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}
.perm-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.perm-actions .btn { flex: 1 1 auto; min-width: 130px; justify-content: center; text-align: center; }
.question-block { border: 1px solid var(--border2); border-radius: 10px; padding: 10px 12px; background: var(--bg2); margin-bottom: 8px; }
.question-header { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #93c5fd; font-weight: 700; margin-bottom: 4px; }
.question-text { font-size: 13.5px; color: var(--text); margin-bottom: 9px; white-space: pre-wrap; line-height: 1.5; }
.question-options { display: flex; flex-direction: column; gap: 6px; }
.question-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 8px 12px;
  color: var(--text);
}
.question-opt:hover { border-color: var(--accent); }
.question-opt.sel { border-color: var(--accent); background: rgba(99, 102, 241, .16); }
.qo-label { font-weight: 650; font-size: 13.5px; }
.qo-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.question-custom {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 8px 12px;
  color: var(--text);
  outline: none;
  margin-top: 8px;
}
.question-custom:focus { border-color: var(--accent); }
.model-info {
  font-size: 12px;
  color: #93c5fd;
  background: none;
  border: none;
  padding: 2px 4px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40%;
  flex: 0 1 auto;
  min-width: 0;
}
.model-info:hover { background: var(--bg3); color: #bfdbfe; }
#btn-send,
#btn-stop {
  flex: none;
  padding: 8px 12px;
  font-size: 16px;
  line-height: 1;
}
#btn-stop { border-color: var(--danger); color: #fca5a5; }
#btn-stop:hover { background: rgba(239, 68, 68, .12); }
#prompt-input.memo { color: var(--muted); font-style: italic; background: var(--bg2); }
#prompt-input.hist { border-color: var(--accent); }
.emoji-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.emoji-pick {
  width: 34px;
  height: 34px;
  font-size: 19px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.emoji-pick:hover { background: var(--bg3); }
.emoji-pick.sel { border-color: var(--accent); background: var(--bg3); }
@media (max-width: 620px) { .emoji-grid { grid-template-columns: repeat(7, 1fr); } }
.modal-hr { border: none; border-top: 1px solid var(--border); margin: 18px 0 14px; }

.child-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.child-edit { opacity: 0; font-size: 13px; padding: 3px 6px; flex: none; }
.child-row:hover .child-edit { opacity: 1; }
@media (hover: none) { .child-edit { opacity: .55; } }
.child-restore { opacity: 0; font-size: 13px; padding: 3px 6px; flex: none; color: #86efac; }
.child-row:hover .child-restore { opacity: 1; }
@media (hover: none) { .child-restore { opacity: .55; } }
.child-badge {
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  color: var(--muted);
  flex: none;
}
.child-badge.done { color: #c4b5fd; border-color: rgba(139,92,246,.42); }
.child-badge.archived { color: #cbd5e1; border-color: rgba(148,163,184,.35); }
.child-live {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none;
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.tree-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 16px; }
.module-block { margin: 1px 0 4px 14px; }
.module-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px 6px 10px;
  border-radius: 9px;
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 13.5px;
}
.module-row:hover { background: var(--bg3); color: var(--text); }
.module-chev { width: 12px; flex: none; font-size: 10px; color: var(--muted); }
.module-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.module-count { font-size: 10.5px; color: var(--muted); background: var(--bg3); border-radius: 20px; padding: 1px 7px; }
.module-edit { opacity: 0; font-size: 12px; padding: 3px 6px; flex: none; }
.module-bilan { opacity: 0; font-size: 12px; padding: 3px 6px; flex: none; }
.module-row:hover .module-edit, .module-row:hover .module-bilan { opacity: 1; }
@media (hover: none) { .module-edit, .module-bilan { opacity: .55; } }
.project-list { margin-left: 14px; }
.btn-add-child {
  margin: 4px 0 0 14px;
  display: block;
  width: calc(100% - 14px);
  text-align: left;
  font-size: 12.5px;
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--border2);
  border-radius: 8px;
  padding: 5px 10px;
}
.project-list .btn-add-child { margin: 4px 0 4px 14px; width: calc(100% - 14px); }
.btn-add-module { margin-top: 6px; color: var(--muted); }
.btn-add-child:hover, .btn-add-module:hover { color: var(--text); border-color: var(--accent); }

.side-foot {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.main { flex: 1; display: flex; min-width: 0; }
.chat-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.plan-panel {
  display: none;
  flex-direction: column;
  width: 320px;
  min-width: 320px;
  border-left: 1px solid var(--border);
  background: var(--bg2);
}
.main.plan-visible .plan-panel { display: flex; }
@media (max-width: 1050px) {
  .main { position: relative; }
  .plan-panel { position: absolute; inset: 0; width: auto; min-width: 0; z-index: 20; }
}
.panel-head { display: flex; align-items: center; gap: 5px; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.panel-tab { background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 5px 10px; font-size: 13px; color: var(--muted); }
.panel-tab:hover { color: var(--text); background: var(--bg3); }
.panel-tab.active { color: var(--text); background: var(--bg3); border-color: var(--border2); font-weight: 650; }
.plan-count { color: var(--muted); font-size: 12px; font-weight: 600; margin-left: auto; }
#btn-plan-close { margin-left: 2px; }
.hist-card { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); padding: 10px 12px; margin-bottom: 10px; }
.hist-date { font-size: 10.5px; color: var(--muted2); margin-bottom: 5px; }
.hist-prompt {
  font-size: 13px;
  color: #c7cdf8;
  font-style: italic;
  white-space: pre-wrap;
  word-break: break-word;
  border-left: 3px solid rgba(99, 102, 241, .55);
  padding-left: 9px;
}
.hist-result { font-size: 13px; }
.hist-result.msg-body { border: none; background: transparent; padding: 0 0 0 9px; border-left: 3px solid rgba(34, 197, 94, .5); border-radius: 0; }
.hist-result p { margin: 6px 0; }
.hist-result pre.code { font-size: 12px; }
.hist-copy { margin-top: 8px; }
.plan-list { flex: 1; overflow-y: auto; padding: 12px; }
.todo-item {
  display: flex;
  gap: 9px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  margin-bottom: 7px;
  background: var(--panel);
  font-size: 13.5px;
  align-items: flex-start;
}
.todo-item .tbox {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1.5px solid var(--border2);
  flex: none;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #052e16;
}
.todo-item .tcontent { flex: 1; min-width: 0; word-break: break-word; }
.todo-item.done { opacity: .55; }
.todo-item.done .tbox { background: var(--ok); border-color: var(--ok); }
.todo-item.done .tcontent { text-decoration: line-through; }
.todo-item.in_progress { border-color: rgba(249,115,22,.55); }
.todo-item.in_progress .tbox { border-color: var(--orange); color: var(--orange); }
.todo-item.cancelled { opacity: .4; }
.todo-item.cancelled .tbox { color: var(--muted); }
.tprio { color: var(--danger); font-weight: 800; flex: none; }
.check-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; padding: 4px 0; cursor: pointer; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  min-height: 54px;
}
.burger { display: none; }
.chat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 1px; }
.ct-line { overflow: hidden; font-size: 14.5px; color: var(--muted); }
.ct-line-inner { display: inline-block; white-space: nowrap; }
/* Défilement doux du titre quand il dépasse (téléphone) : va jusqu'au bout,
   marque une pause, revient. --marquee-distance/duration posés en JS. */
.ct-line-inner.marquee {
  animation: ctMarquee var(--marquee-duration, 8s) ease-in-out infinite;
}
@keyframes ctMarquee {
  0%, 10% { transform: translateX(0); }
  45%, 55% { transform: translateX(var(--marquee-distance, 0px)); }
  90%, 100% { transform: translateX(0); }
}
.ct-dates { font-size: 11px; color: var(--muted2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title .ct-mother { font-weight: 700; color: var(--text); }
.chat-actions { display: flex; gap: 6px; flex: none; }

.prompt-zone {
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex: none;
}
/* File d'attente : intégrée en tête de la zone de saisie (même composer,
   section distincte). Ordre d'affichage : plus récent en haut, prochain en bas. */
.queuebar {
  margin: 10px 0 0;
  padding: 10px 12px 11px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(99, 102, 241, .14), rgba(99, 102, 241, .05));
  border: 1px solid rgba(99, 102, 241, .38);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}
.queuebar.hidden { display: none; }

.queue-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  font-size: 12px;
  min-width: 0;
}
.queue-head-icon { font-size: 13px; line-height: 1; }
.queue-head-title { font-weight: 700; color: #c7d2fe; white-space: nowrap; }
.queue-head-sub {
  color: var(--muted);
  margin-left: auto;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 34vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}
.queue-list::-webkit-scrollbar { width: 6px; }
.queue-list::-webkit-scrollbar-thumb { background: rgba(129, 140, 248, .4); border-radius: 6px; }

.queue-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 10px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.queue-row:hover { border-color: rgba(129, 140, 248, .5); }
.queue-row.next {
  background: rgba(99, 102, 241, .18);
  border-color: #818cf8;
  box-shadow: 0 0 0 1px rgba(129, 140, 248, .28), 0 4px 12px rgba(0, 0, 0, .2);
}

.queue-badge {
  flex: none;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1;
  background: var(--bg3);
  color: var(--muted);
}
.queue-row.next .queue-badge { background: #818cf8; color: #0b1020; }

.queue-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.queue-text:hover { color: #c7d2fe; }

.queue-actions { display: flex; align-items: center; gap: 5px; flex: none; }
.queue-act {
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--muted);
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 12px;
  line-height: 1.1;
  transition: background .15s, border-color .15s, color .15s;
}
.queue-act:hover { color: var(--text); border-color: var(--accent); }
.queue-act.force { color: #c7d2fe; border-color: rgba(129, 140, 248, .5); }
.queue-act.force:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.queue-act.danger:hover { color: #fecaca; border-color: var(--danger); background: rgba(239, 68, 68, .12); }
.promptbar { padding: 10px 16px 12px; }
/* Sous-prompts : une seule ligne, défilement horizontal (droite/gauche). */
.snippet-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-bottom: 0;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 149, 173, .4) transparent;
  padding-bottom: 2px;
}
.snippet-chips:not(:empty) { margin-bottom: 8px; }
.snippet-chips::-webkit-scrollbar { height: 5px; }
.snippet-chips::-webkit-scrollbar-track { background: transparent; }
.snippet-chips::-webkit-scrollbar-thumb { background: rgba(139, 149, 173, .35); border-radius: 6px; }
.snippet-chips::-webkit-scrollbar-thumb:hover { background: rgba(139, 149, 173, .55); }
.chip {
  flex: none;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 2px 11px;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
#prompt-input {
  width: 100%;
  resize: vertical;
  min-height: 74px;
  max-height: 40vh;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 10px 13px;
  outline: none;
  line-height: 1.5;
}
#prompt-input:focus { border-color: var(--accent); }
.promptbar-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.hist-nav-btns { display: flex; gap: 4px; flex: none; }
.hist-nav-btns .btn { padding: 4px 9px; font-size: 12px; line-height: 1; }
/* Écran tactile : la navigation d'historique passe par le geste dans la zone
   de prompt — les flèches ▲▼ ne servent qu'aux pointeurs fins (souris). */
@media (hover: none) and (pointer: coarse) {
  #hist-nav { display: none; }
}
.prompt-hint {
  font-size: 11.5px;
  color: var(--muted);
  flex: 1 1 0;
  min-width: 0;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat { flex: 1; overflow-y: auto; padding: 18px 18px 30px; overflow-anchor: auto; }
.chat-inner { max-width: 860px; margin: 0 auto; }
.msg { margin-bottom: 18px; display: flex; flex-direction: column; }
.msg.user { align-items: flex-end; }
.msg.user .msg-head { justify-content: flex-end; }
.msg-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.msg-role { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .7px; padding: 2px 9px; border-radius: 20px; }
.msg.user .msg-role { background: var(--indigo); color: #fff; }
.msg.assistant .msg-role { background: rgba(34,197,94,.14); color: #86efac; }
.msg-synth { font-size: 11.5px; color: #86efac; }

/* Notification de fallback (bascule automatique de modèle) : bannière centrée
   verte, clairement distincte des messages de l'utilisateur. */
.fallback-notice {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}
.fallback-notice-inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 92%;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #86efac;
  background: rgba(34, 197, 94, .1);
  border: 1px solid rgba(34, 197, 94, .38);
  border-radius: 20px;
  padding: 5px 14px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .18);
}
.msg-foot { font-size: 11.5px; color: var(--muted); margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; }

.msg-body {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 15px;
  background: var(--panel);
}
.msg.user .msg-body {
  max-width: 78%;
  background: linear-gradient(135deg, #4338ca, #6366f1);
  border: none;
  color: #f1f5ff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 4px 16px rgba(79,70,229,.28);
}
.msg.user .msg-body a { color: #c7d2fe; }
.msg.user .msg-body code { background: rgba(255,255,255,.16); border-color: transparent; color: #fff; }
.msg.user .msg-body pre.code { background: rgba(0,0,0,.28); border-color: transparent; }
.msg.user .msg-body blockquote { color: #c7d2fe; border-left-color: rgba(255,255,255,.4); }
.msg.assistant .msg-body { border-left: 3px solid rgba(34,197,94,.45); border-radius: 4px 16px 16px 16px; }
@media (max-width: 900px) { .msg.user .msg-body { max-width: 88%; } }
.msg-body > :first-child { margin-top: 0; }
.msg-body > :last-child { margin-bottom: 0; }
.msg-body p { margin: 8px 0; }
.msg-body h3, .msg-body h4 { margin: 14px 0 6px; }
.msg-body ul { margin: 8px 0; padding-left: 22px; }
.msg-body blockquote {
  margin: 8px 0;
  padding: 4px 12px;
  border-left: 3px solid var(--border2);
  color: var(--muted);
}
.msg-body code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 13px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.msg-body pre.code {
  background: #070b14;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  margin: 10px 0;
  white-space: pre;
}
.msg-body a { color: #93c5fd; }

.reasoning {
  margin: 0 0 10px;
  border: 1px dashed var(--border2);
  border-radius: 9px;
  background: rgba(139,92,246,.05);
}
.reasoning summary {
  cursor: pointer;
  padding: 7px 12px;
  font-size: 12px;
  color: #c4b5fd;
  font-weight: 600;
  user-select: none;
  list-style: none;
}
.reasoning summary::before { content: "◆ "; }
.reasoning[open] summary { border-bottom: 1px dashed var(--border2); }
.reasoning-body {
  padding: 9px 13px;
  font-size: 12.5px;
  color: #a8b0c8;
  white-space: pre-wrap;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  max-height: 300px;
  overflow-y: auto;
}

.tool-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  margin: 8px 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 11px;
}
.tool-name { font-weight: 650; color: #93c5fd; }
.tool-status { font-size: 11px; padding: 1px 8px; border-radius: 20px; background: var(--bg3); }
.tool-status.running { color: #fde68a; }
.tool-status.ok { color: #86efac; }
.tool-status.error { color: #fca5a5; }
.tool-detail { margin-left: auto; }
.tool-detail summary { cursor: pointer; font-size: 11.5px; color: var(--muted); user-select: none; }
.tool-io {
  margin: 8px 0 0;
  background: #070b14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow-y: auto;
  color: #9fb0d0;
}

.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: typingBounce 1.2s ease-in-out infinite;
  will-change: transform, opacity;
}
.typing span:nth-child(2) { animation-delay: .16s; }
.typing span:nth-child(3) { animation-delay: .32s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  color: var(--muted);
  gap: 8px;
  overflow-y: auto;
  padding: 26px 20px 30px;
}
.home-wrap { width: 100%; max-width: 980px; margin: 0 auto; }
.home-title { font-size: 24px; font-weight: 800; color: var(--text); }
.home-sub-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 5px 0 24px; }
.home-sub { color: var(--muted); font-size: 14px; }
.home-view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.home-view-toggle button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
}
.home-view-toggle button:hover { color: var(--text); background: var(--bg3); }
.home-view-toggle button.active { background: var(--accent); color: #fff; }
.home-model-btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home-model-btn:hover { border-color: var(--accent); }
.home-mother { margin-bottom: 28px; }
/* Menu discret « ⋮ » de navigation (mère › modules › projets) sur la page Home */
.home-nav-wrap { position: relative; display: inline-flex; align-items: center; margin-left: auto; }
.home-nav-btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 3px;
}
.home-nav-btn:hover { color: var(--text); border-color: var(--accent); background: var(--bg3); }
.home-nav-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  max-width: 330px;
  max-height: 62vh;
  overflow-y: auto;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
  padding: 5px;
  z-index: 38;
}
.hnm-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.hnm-row:hover { background: var(--bg3); }
.hnm-row .module-chev { color: var(--muted); flex: none; width: 12px; }
.hnm-row .hnm-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hnm-row .hnm-count { color: var(--muted2); font-size: 11.5px; flex: none; }
.hnm-row .hnm-dot { flex: none; }
/* ⋮ contextuel sur mères / modules / projets de la page Home */
.home-item-menu-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted2);
  font-size: 15px;
  line-height: 1;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 2px;
  flex: none;
}
.home-item-menu-btn:hover { color: var(--text); background: var(--bg3); border-color: var(--border); }
.home-card .home-item-menu-btn { position: absolute; top: 7px; right: 7px; }
.home-nav-menu.item-menu {
  position: fixed;
  min-width: 215px;
  max-width: calc(100vw - 16px);
  max-height: 70vh;
}
.hnm-item .hnm-icon { width: 18px; flex: none; text-align: center; }
.hnm-item.danger { color: var(--danger); }
.hnm-mother { font-weight: 700; }
.hnm-module { padding-left: 26px; font-weight: 600; color: var(--muted); }
.hnm-module:hover { color: var(--text); }
.hnm-project { padding-left: 42px; font-weight: 500; }
.hnm-project.archived { opacity: .55; }
.hnm-empty { color: var(--muted); cursor: default; }
.hnm-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.hnm-pref { color: var(--muted); font-weight: 600; }
.hnm-pref:hover { color: var(--accent); }
.home-mother-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  font-weight: 750;
  font-size: 16.5px;
  color: var(--text);
  margin-bottom: 8px;
}
.hmh-left {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  border-radius: 8px;
  padding: 2px 4px;
}
.hmh-left:hover { color: var(--accent); }
.hmh-bilan { flex: none; }
.home-module-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin: 12px 0 8px;
}
.home-module-label .hml-name {
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  padding: 0;
  cursor: pointer;
}
.home-module-label .hml-name:hover { color: var(--accent); text-decoration: underline; }
.home-module-label .hml-bilan { text-transform: none; letter-spacing: 0; padding: 1px 8px; font-size: 11px; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-rows: 1fr; gap: 7px; }
.home-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  height: 100%;
  min-height: 64px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 30px 8px 10px;
  color: var(--text);
}
.home-card:hover { border-color: var(--accent); background: var(--bg3); }
.home-card.archived { opacity: .6; }
.hc-title { font-size: 12.5px; font-weight: 650; display: flex; align-items: flex-start; gap: 6px; line-height: 1.25; align-self: stretch; min-width: 0; }
.hc-date { font-size: 10px; color: var(--muted2); }
.home-list { display: flex; flex-direction: column; gap: 6px; }
.home-row {
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--text);
}
.home-row:hover { border-color: var(--accent); background: var(--bg3); }
.home-row.archived { opacity: .6; }
.hr-title {
  font-size: 13.5px;
  font-weight: 650;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 7px;
  line-height: 1.25;
}
.hr-title .ttl, .hc-title .ttl {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  min-width: 0;
}
.hr-date { font-size: 11px; color: var(--muted2); flex: none; }
.home-card, .home-row { touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.home-card.swipeable, .home-row.swipeable { position: relative; overflow: hidden; }
.swipe-hint {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 750;
  padding: 4px 10px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s linear;
  z-index: 1;
}
.swipe-hint.right { right: 12px; color: #22c55e; background: rgba(34,197,94,.15); }
.swipe-hint.left { left: 12px; color: #eab308; background: rgba(234,179,8,.14); }
/* Révélation « derrière la carte » : le glisser à gauche ouvre la carte et
   laisse apparaître les deux boutons ★ / 🔵 à droite, à la hauteur de la
   carte (mode cartes uniquement). */
.swipe-wrap { position: relative; display: grid; }
.swipe-wrap .swipe-card { z-index: 1; }
.swipe-actions {
  position: absolute; top: 0; bottom: 0; z-index: 0;
  display: flex; align-items: stretch; gap: 6px; padding: 3px;
  border-radius: 9px;
  visibility: hidden;   /* une seule rangée visible à la fois (selon le geste) */
}
.swipe-actions.right-side { right: 0; width: 156px; }   /* ★ + 🔵 (glisser gauche) */
.swipe-actions.left-side { left: 0; width: 110px; }     /* ✔ Fini violet (glisser droite) */
.swipe-act {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 4px;
  font: inherit; font-size: 11px; font-weight: 700; line-height: 1.15;
  border: none; border-radius: 7px; cursor: pointer;
  background: rgba(234,179,8,.2); color: #eab308;
}
.swipe-act .swipe-act-ico { font-size: 17px; line-height: 1; }
.swipe-act.blue { background: rgba(59,130,246,.2); color: #60a5fa; }
/* Carte glissée « à fond » : le 🔵 s'allume ➔ relâcher = « fini » direct */
.swipe-act.blue.armed { background: #3b82f6; color: #fff; box-shadow: 0 0 14px rgba(59,130,246,.55); }
/* Option « ✔ Fini » violette (côté droit du swipe, thème du logo --violet) */
.swipe-act.done { background: rgba(139,92,246,.22); color: #c4b5fd; }
.swipe-act.done.armed { background: #8b5cf6; color: #fff; box-shadow: 0 0 14px rgba(139,92,246,.55); }
.swipe-act:active { filter: brightness(1.3); }
.proj-star { color: #eab308; font-size: 13px; flex: none; text-shadow: 0 0 6px rgba(234,179,8,.35); }

.bilan-welcome {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  margin: 8px 0;
}
.bilan-welcome-title {
  font-size: 16.5px;
  font-weight: 750;
  color: var(--text);
  margin-bottom: 8px;
}
.bilan-welcome-sub {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 16px;
}
.bilan-welcome-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 900px) {
  .empty { padding: 18px 12px 24px; }
  .home-grid { grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); }
  .hr-date { display: none; }
}

.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(4,7,14,.66);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 18px;
}
.modal-root.full-open {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  background: var(--bg);
  backdrop-filter: none;
}
.modal {
  width: min(620px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 22px 22px 18px;
  box-shadow: 0 30px 90px rgba(0,0,0,.6);
}
.modal.modal-full {
  width: 100%;
  max-width: 100%;
  height: 100vh;
  max-height: 100vh;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  background: var(--bg);
}
.settings-page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 18px 56px;
}
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.settings-head h2 { margin: 0; font-size: 20px; }
.modal-card canvas { max-width: 100%; }
.modal-card > div[style*="height"] { position: relative; }
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 650; color: var(--muted); margin-bottom: 6px; }
.field input[type="text"], .field input[type="password"], .field textarea, .field select {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 9px 12px;
  outline: none;
  color: var(--text);
}
.field select option { background: #161d2f; color: #e5eaf4; }
.field textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 30px; height: 30px; border-radius: 9px; border: 2px solid transparent; cursor: pointer;
}
.swatch.sel { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.18); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.modal-actions .left { margin-right: auto; }
.snippet-row {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 13px; margin-bottom: 9px; background: var(--bg2);
}
.snippet-row .sn-title { font-weight: 650; font-size: 14px; }
.snippet-row .sn-body { color: var(--muted); font-size: 12.5px; margin-top: 3px; white-space: pre-wrap; max-height: 70px; overflow: hidden; }
.snippet-row .sn-actions { margin-left: auto; display: flex; gap: 5px; flex: none; }
.snippet-row .sn-main { flex: 1; min-width: 0; }
.snippet-row .tree-handle { margin-top: 1px; }
.snippet-row:hover .tree-handle { opacity: .95; }
.snippet-row.tree-dragging { opacity: .5; outline: 2px dashed var(--accent); outline-offset: -2px; }

.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }

/* Bandeau « Nouvelle version disponible » (mécanisme copié de Silas :
   comparaison du Last-Modified du shell servi vs celui chargé). */
.app-update-offer {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 10px;
  max-width: 360px;
  margin: 0 auto;
  background: #1e293b;
  color: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 16px 32px -8px rgba(0, 0, 0, .5);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-update-offer .auo-icon { font-size: 18px; flex-shrink: 0; }
.app-update-offer .auo-title { font-weight: 600; font-size: 12.5px; line-height: 1.2; }
.app-update-offer .auo-sub { font-size: 10.5px; color: #cbd5e1; margin-top: 1px; }
.app-update-offer .auo-btn {
  font-size: 11px;
  background: #fff;
  color: #1e293b;
  border: none;
  border-radius: 6px;
  padding: 5px 9px;
  font-weight: 700;
  flex-shrink: 0;
  cursor: pointer;
}
.app-update-offer .auo-btn:hover { background: #e2e8f0; }
.app-update-offer .auo-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 13px;
  padding: 2px 6px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 4px;
}
.app-update-offer .auo-close:hover { color: #fff; background: rgba(255, 255, 255, .15); }
.toast {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  animation: toastin .18s ease-out;
  max-width: 340px;
}
.toast.error { border-left-color: var(--danger); }
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; }

/* Tooltip & Quota / Fallback Widget */
.oc-tooltip {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.zen-header-widget {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: auto;
  flex: 1 1 260px;
  max-width: 400px;
  margin-left: auto;
  font-size: 11px;
}
.oc-go-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#oc-mammouth-line, #oc-fallback-line, [data-oc-seg] {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.oc-row-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.oc-lb {
  width: 52px;
  text-align: right;
  color: var(--muted);
  flex-shrink: 0;
  font-size: 10.5px;
}
.oc-bar-track {
  flex: 1;
  height: 7px;
  border-radius: 4px;
  background: var(--border2);
  overflow: hidden;
}
.oc-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .3s ease;
}
.oc-pct {
  width: 32px;
  text-align: right;
  font-weight: 600;
  font-size: 10.5px;
}
.oc-reset-track {
  margin-left: 58px;
  height: 2px;
  border-radius: 2px;
  background: var(--border2);
  overflow: hidden;
}
.oc-reset-fill {
  height: 100%;
  border-radius: 2px;
}
.oc-fallback-box {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text);
}
.oc-seg-wrap {
  display: flex;
  gap: 3px;
  height: 4px;
  margin-bottom: 3px;
}
@keyframes ocSegPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.oc-seg-active {
  animation: ocSegPulse 2s infinite ease-in-out;
}

/* Modal Tab & Section Cards */
.modal-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  padding-bottom: 8px;
}
.settings-page .modal-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  flex-wrap: wrap;
}
.modal-tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.modal-tab-btn.active {
  background: var(--bg3);
  color: var(--text);
}
.modal-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.modal-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.modal-card-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.zen-free-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  text-align: left;
}
.zen-free-table th {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.zen-free-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border2);
  color: var(--text);
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset: 0 18% 0 0;
    z-index: 45;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 30px 0 60px rgba(0,0,0,.4);
  }
  .sidebar.open { transform: none; }
  .burger { display: inline-block; }
  .chat { padding: 12px 10px 20px; }
  .promptbar { padding: 8px 10px 10px; }
  .promptbar-foot { gap: 6px; margin-top: 6px; }
  .queuebar { padding: 8px 9px 9px; border-radius: 11px; }
  .queue-head-sub { display: none; }
  .queue-row { gap: 7px; padding: 6px 7px; }
  .queue-act { padding: 4px 7px; }
  .model-info { max-width: 34%; font-size: 11px; }
  .prompt-hint { font-size: 11px; }
  .hist-nav-btns .btn { padding: 4px 7px; }
  .settings-page { padding: 12px 12px 40px; }
  .settings-head h2 { font-size: 17px; }
  .modal-tab-btn { font-size: 13px; padding: 6px 9px; }
  .chat-head { padding: 8px 10px; }
  .fab { bottom: 18px; right: 12px; }
  .home-btn { display: none !important; }
}

/* FAB « + » de la page d'accueil (inspiré de Silas) */
.fab {
  position: fixed;
  bottom: 22px;
  right: 16px;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  background: #22c55e;
  color: #fff;
  font-size: 36px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .35);
  cursor: pointer;
  z-index: 30;
  transition: background .2s ease, transform .2s ease;
}
.fab:hover { background: #16a34a; }
.fab:active { transform: scale(.94); }

/* Sélecteur de modèle (plan ➔ modèle) */
.mp-plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.mp-plan {
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 6px;
  cursor: pointer;
  text-align: center;
}
.mp-plan:hover { border-color: var(--accent); background: var(--bg2); }
.mp-plan .mp-plan-label { font-size: 13.5px; font-weight: 700; display: block; }
.mp-plan .mp-plan-count { font-size: 11px; color: var(--muted); }
.mp-plan.cur { border-color: var(--accent); background: rgba(99, 102, 241, .14); }
.mp-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; max-height: 46vh; overflow-y: auto; }
.mp-model {
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-family: ui-monospace, monospace;
}
.mp-model:hover { border-color: var(--accent); background: var(--bg2); }
.mp-model.cur { border-color: var(--accent); background: rgba(99, 102, 241, .14); }
.mp-back {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}
.mp-back:hover { color: var(--text); }
.mp-filter {
  width: 100%;
  margin-top: 10px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 7px 11px;
  color: var(--text);
  outline: none;
  font-size: 13px;
}

/* Fallback Manager */
.fb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  gap: 8px;
}
.fb-row-idx {
  font-weight: 700;
  font-size: 12px;
  color: var(--accent);
  min-width: 20px;
}
.fb-row-info {
  flex: 1;
  min-width: 0;
}
.fb-row-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fb-row-key {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fb-row-actions {
  display: flex;
  gap: 4px;
}
.mp-filter:focus { border-color: var(--accent); }

/* ── Ordre de lecture du LLM : glisser-déposer des pré-prompts ─────────── */
.vp-list { display: flex; flex-direction: column; gap: 10px; }
.vp-row {
  border: 1px solid var(--border);
  background: var(--bg2);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.vp-row textarea {
  width: 100%;
  resize: vertical;
  font-size: 12.5px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 8px 10px;
  outline: none;
  color: var(--text);
  line-height: 1.5;
}
.vp-row-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.vp-num {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vp-title { font-size: 12.5px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-handle {
  flex: none;
  cursor: grab;
  color: var(--muted);
  font-size: 14px;
  padding: 2px 4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.vp-row.draggable { cursor: grab; }
.vp-row.dragging { opacity: .55; border-style: dashed; border-color: var(--accent); }

/* ── Glisser-déposer de l'arbre (mères / modules / projets) ────────────── */
.tree-handle {
  flex: none;
  cursor: grab;
  color: var(--muted);
  font-size: 13px;
  opacity: 0.35;
  padding: 0 4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.15s;
}
.mother-row:hover .tree-handle,
.module-row:hover .tree-handle,
.child-row:hover .tree-handle,
.hnm-row:hover .tree-handle {
  opacity: 0.95;
}
.tree-dragging {
  opacity: 0.5;
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  border-radius: 9px;
}
