/* Command Center > Assistant ------------------------------------------------
   The conversation is the product. The page is a working surface, not a
   dashboard: one column, a dense thread, and the run controls docked to the
   composer where the decision is actually made. */

/* The Assistant owns the viewport: the thread and the conversation list scroll
   independently and the composer never leaves the screen. dvh keeps this true
   when mobile browser chrome appears; min-height:0 lets the inner flex chain
   actually shrink instead of pushing content off-screen. */
.workspace:has(.assistant-workspace) {
  padding-bottom: 22px;
  overflow: hidden;
}

.assistant-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  height: calc(100dvh - var(--topbar-height) - 44px);
  min-height: 0;
  overflow: hidden;
}

.assistant-workspace.with-history { grid-template-columns: 232px minmax(0, 1fr); }

.assistant-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
}

/* Conversation history --------------------------------------------------- */

.assistant-history {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}

.assistant-history > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border);
}

.assistant-history > header strong { font-size: 12px; }

.assistant-history-new {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.assistant-history-new:hover { color: var(--accent); border-color: var(--line-strong); }
.assistant-history-new i { width: 13px; height: 13px; }

.assistant-history-list {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding: 8px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.assistant-history-item { display: flex; align-items: center; border-radius: 9px; }
.assistant-history-item:hover { background: var(--surface-soft); }
.assistant-history-item.is-active { background: var(--blue-soft); }

.assistant-history-item.is-archived .assistant-history-open strong {
  color: var(--muted);
  font-style: italic;
}

.assistant-history-open {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 9px;
  border: 0;
  background: transparent;
  text-align: left;
}

.assistant-history-open strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-history-open small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.assistant-history-actions {
  display: none;
  align-items: center;
  gap: 1px;
  padding-right: 6px;
}

.assistant-history-item:hover .assistant-history-actions,
.assistant-history-item.is-active .assistant-history-actions { display: flex; }

.assistant-history-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.assistant-history-actions button:hover { color: var(--text); background: var(--surface); }
.assistant-history-actions i { width: 12px; height: 12px; }

.assistant-rename-form { flex: 1 1 auto; padding: 5px 6px; }

.assistant-rename-form input {
  width: 100%;
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--surface);
  font-family: inherit;
  font-size: 12px;
}

.assistant-history-empty { margin: 12px 9px; color: var(--muted); font-size: 11.5px; }

.assistant-history > footer { padding: 9px 12px; border-top: 1px solid var(--border); }

.assistant-history-archived {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10.5px;
  cursor: pointer;
}

.assistant-history-archived input {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: var(--accent);
}

.assistant-route-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.assistant-route-status i { width: 12px; height: 12px; }
.assistant-route-status.is-ready i { color: var(--green); }

.assistant-route-status.is-blocked {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 26%, var(--border));
  background: var(--red-soft);
}

.assistant-turn.is-compact { gap: 8px; opacity: 0.72; }

.assistant-run-compact {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
}

.assistant-run-compact i { width: 13px; height: 13px; flex: 0 0 13px; }

/* Route bar --------------------------------------------------------------- */

.assistant-route-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex: 0 0 auto;
}

.assistant-route-identity {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.assistant-route-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  color: white;
  background: var(--brand-gradient);
}

.assistant-route-avatar i {
  width: 17px;
  height: 17px;
}

.assistant-route-identity strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.assistant-route-identity small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-route-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.assistant-route-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.assistant-route-chip i {
  width: 13px;
  height: 13px;
}

.assistant-route-chip.is-ready {
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 26%, var(--border));
  background: var(--green-soft);
}

.assistant-route-chip.is-blocked {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 26%, var(--border));
  background: var(--red-soft);
}

.assistant-route-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.assistant-route-action:hover {
  color: var(--accent);
  border-color: var(--line-strong);
}

.assistant-route-action i {
  width: 14px;
  height: 14px;
}

.assistant-route-blocked {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--red) 24%, var(--border));
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 12px;
}

.assistant-route-blocked i {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
}

/* Conversation ------------------------------------------------------------ */

.assistant-conversation {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  gap: 12px;
}

.assistant-workspace .assistant-thread {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 34px;
  min-height: 0;
  max-height: none;
  padding: 4px 2px 8px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.assistant-turn {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
}

.assistant-request {
  align-self: flex-end;
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px 14px 4px 14px;
  background: var(--blue-soft);
}

.assistant-request p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.assistant-response {
  min-width: 0;
}

.assistant-answer {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.62;
}

.assistant-answer p {
  margin: 0 0 11px;
  white-space: normal;
}

.assistant-answer p:last-child {
  margin-bottom: 0;
}

.assistant-answer code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-soft);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.assistant-answer pre {
  margin: 0 0 11px;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.assistant-answer pre code {
  padding: 0;
  background: transparent;
  font-size: 11.5px;
  line-height: 1.55;
}

.assistant-answer ul,
.assistant-answer ol {
  margin: 0 0 11px;
  padding-left: 20px;
}

.assistant-answer li {
  margin-bottom: 4px;
}

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

.assistant-answer h3,
.assistant-answer h4 {
  margin: 16px 0 7px;
  font-size: 13.5px;
  font-weight: 700;
}

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

.assistant-answer pre[data-language]::before {
  content: attr(data-language);
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.assistant-answer-error {
  margin: 0;
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, var(--red) 22%, var(--border));
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 12.5px;
  line-height: 1.55;
}

.assistant-answer-error p {
  margin: 0;
}

.assistant-answer-error details {
  margin-top: 8px;
}

.assistant-answer-error summary {
  color: color-mix(in srgb, var(--red) 78%, var(--text));
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.assistant-answer-error pre {
  margin: 7px 0 0;
  max-height: 220px;
  padding: 9px 10px;
  overflow: auto;
  border-radius: 8px;
  background: color-mix(in srgb, white 55%, var(--red-soft));
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.assistant-working {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.assistant-working-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: assistant-pulse 1.15s ease-in-out infinite;
}

@keyframes assistant-pulse {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.assistant-run-events {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.assistant-run-events li {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11.5px;
}

.assistant-run-events li.is-done {
  color: var(--green);
}

.assistant-run-events i {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
}

.assistant-run-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 14px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 10.5px;
}

.assistant-run-route {
  font-weight: 600;
  color: color-mix(in srgb, var(--text) 62%, var(--muted));
}

.assistant-run-numbers {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 400;
}

.assistant-run-numbers b {
  font-weight: 400;
  cursor: default;
}

.assistant-run-state {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 600;
}

.assistant-run-state.is-completed {
  background: var(--green-soft);
  color: var(--green);
}

.assistant-run-state.is-running,
.assistant-run-state.is-queued {
  background: var(--blue-soft);
  color: var(--brand-blue-dark);
}

.assistant-run-state.is-failed,
.assistant-run-state.is-awaiting_runtime {
  background: var(--red-soft);
  color: var(--red);
}

.assistant-run-state.is-awaiting_approval {
  background: var(--yellow-soft);
  color: var(--yellow);
}

.assistant-run-detail {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-size: 10px;
  text-decoration: underline;
}

/* Empty and boot states --------------------------------------------------- */

.assistant-empty,
.assistant-boot {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.assistant-empty > span {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  color: white;
  background: var(--brand-gradient);
}

.assistant-empty h2 {
  margin: 0;
  font-size: 20px;
}

.assistant-empty p,
.assistant-boot p {
  max-width: 440px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.assistant-boot i {
  width: 20px;
  height: 20px;
  color: var(--muted);
}

/* Composer ---------------------------------------------------------------- */

.assistant-workspace .assistant-composer {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 10px 10px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 6px 22px rgb(13 71 161 / 6%);
}

.assistant-workspace .assistant-composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 44%, var(--line-strong));
  box-shadow: 0 6px 26px rgb(13 71 161 / 10%);
}

.assistant-workspace .assistant-composer textarea {
  width: 100%;
  min-height: 24px;
  max-height: 220px;
  padding: 2px 4px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.55;
  resize: none;
}

.assistant-workspace .assistant-composer textarea::placeholder {
  color: var(--muted);
}

.assistant-composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* One desktop line, in route order:
   Pièce jointe | Agent | Engine | Access | Model | Reasoning | Advanced,
   with Envoyer pinned right.

   Every control shrinks before anything is hidden. `overflow: hidden` alone
   used to clip the rightmost controls out of existence once Access joined the
   row — a control the user could no longer see or reach. They now ellipsise
   instead, and Model keeps absorbing the free width. */
.assistant-composer-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
  flex-wrap: nowrap;
}

.assistant-control,
.assistant-advanced-toggle,
.assistant-file-button {
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
}

/* Each route control carries its own icon so Agent, Engine, Model and Effort
   stay distinguishable without spending vertical space on labels. */
.assistant-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  /* Shrinkable down to icon + a readable stub, never below it. */
  max-width: 168px;
  flex: 0 1 auto;
  padding: 0 5px 0 7px;
}

/* Model carries the longest, least predictable labels ("Claude Opus 5",
   "GPT-5.6 Sol", 1M-context variants). It therefore claims the free width
   first and yields it last, instead of being the control that gets squeezed. */
.assistant-control.is-flexible {
  flex: 3 1 150px;
  max-width: none;
}

/* Agent, Engine, Access and Reasoning hold short, stable values: they give way
   before Model does. */
.assistant-control:not(.is-flexible) {
  flex: 0 2 auto;
  max-width: 140px;
}

.assistant-control > i {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  color: var(--muted);
}

.assistant-control select {
  width: 100%;
  min-width: 0;
  /* Follows the control instead of a fixed cap, so shrinking is gradual. */
  max-width: none;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
}

.assistant-control.is-flexible select {
  max-width: none;
}

.assistant-file-button,
.assistant-advanced-toggle,
.assistant-send-button,
.assistant-stop-button {
  flex: 0 0 auto;
}

.assistant-advanced-toggle {
  white-space: nowrap;
}

.assistant-control:hover:has(select:enabled),
.assistant-advanced-toggle:hover:enabled,
.assistant-file-button:hover {
  border-color: var(--line-strong);
}

.assistant-control:focus-within {
  border-color: color-mix(in srgb, var(--accent) 44%, var(--line-strong));
}

.assistant-control:has(select:disabled),
.assistant-advanced-toggle:disabled {
  opacity: 0.45;
}

.assistant-file-button,
.assistant-advanced-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  cursor: pointer;
}

.assistant-file-button {
  width: 28px;
  padding: 0;
  justify-content: center;
}

.assistant-advanced-toggle.is-open {
  color: var(--brand-blue-dark);
  border-color: var(--line-strong);
  background: var(--blue-soft);
}

.assistant-file-button i,
.assistant-advanced-toggle i {
  width: 13px;
  height: 13px;
}

.assistant-send-button,
.assistant-stop-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 0;
  border-radius: 9px;
  color: white;
  background: var(--brand-gradient);
}

.assistant-send-button:disabled {
  opacity: 0.4;
}

.assistant-stop-button {
  background: var(--text);
}

.assistant-send-button i,
.assistant-stop-button i {
  width: 15px;
  height: 15px;
}

.assistant-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.assistant-attachments span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: 11px;
}

.assistant-attachments i {
  width: 12px;
  height: 12px;
}

.assistant-attachments button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}

.assistant-attachments button:hover {
  color: var(--red);
  background: var(--red-soft);
}

/* Advanced ---------------------------------------------------------------- */

.assistant-advanced {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 2px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
}

.assistant-advanced-primary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  align-items: start;
}

/* Permissions, identité, workspace et contexte tiennent sur une ligne dès que
   la largeur le permet ; deux par deux ensuite. */
@media (min-width: 1180px) {
  .assistant-advanced-primary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.assistant-identity-select {
  width: 100%;
  padding: 6px 8px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11.5px;
}

.assistant-identity-select:focus-visible {
  outline: 0;
  border-color: #5794dc;
  box-shadow: 0 0 0 3px rgba(64, 139, 225, 0.16);
}

.assistant-identity-note {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.45;
}

.assistant-advanced-mono {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  overflow-wrap: anywhere;
}

.assistant-advanced-details > summary {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.assistant-advanced-details > summary::-webkit-details-marker {
  display: none;
}

.assistant-advanced-details > summary::before {
  content: "▸ ";
}

.assistant-advanced-details[open] > summary::before {
  content: "▾ ";
}

.assistant-advanced-details > summary:hover {
  color: var(--text);
}

.assistant-advanced-technical {
  display: grid;
  gap: 6px;
  margin: 9px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.assistant-advanced-technical > div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}

.assistant-advanced-technical dt {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.assistant-advanced-technical dd {
  margin: 0;
  color: var(--text);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.assistant-advanced-technical dd em {
  color: var(--muted);
  font-style: normal;
}

.assistant-advanced-field > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.assistant-advanced-field p {
  margin: 0;
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.5;
}

.assistant-advanced-field em {
  color: var(--muted);
  font-style: normal;
}

.assistant-permission-choice {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.assistant-permission-choice label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.assistant-permission-choice label.is-active {
  color: var(--brand-blue-dark);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--blue-soft);
}

.assistant-permission-choice label.is-unavailable {
  opacity: 0.5;
  cursor: not-allowed;
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent);
}

.assistant-permission-choice input {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: var(--accent);
}

/* Responsive -------------------------------------------------------------- */

@media (max-width: 1100px) {
  .assistant-workspace.with-history { grid-template-columns: 190px minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .assistant-workspace {
    height: calc(100dvh - var(--topbar-height) - 44px);
  }

  .assistant-workspace.with-history { grid-template-columns: minmax(0, 1fr); }
  .assistant-history { display: none; }

  .assistant-advanced-primary {
    grid-template-columns: 1fr;
  }

  .assistant-route-identity small {
    display: none;
  }
}

@media (max-width: 720px) {
  .assistant-composer-controls {
    flex-wrap: wrap;
    overflow: visible;
  }

  .assistant-control {
    max-width: 140px;
  }

  .assistant-control select {
    max-width: 104px;
  }

  .assistant-advanced-technical > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .assistant-route-chip {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* AI > Memory cockpit -------------------------------------------------------
   Sessions, Agent, Project and Working memory are different objects and must
   never read as one undifferentiated pile. */

.memory-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #f3f6fa;
}

.memory-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
}

.memory-tabs button:hover { color: var(--text); }

.memory-tabs button.is-active {
  color: var(--brand-blue-dark);
  background: var(--surface);
  box-shadow: 0 2px 7px rgb(15 23 42 / 8%);
}

.memory-tabs i { width: 14px; height: 14px; }

.memory-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.memory-kpi-grid article {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.memory-kpi-grid small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.memory-kpi-grid strong { display: block; margin: 7px 0 4px; font-size: 22px; }
.memory-kpi-grid span { color: var(--muted); font-size: 11.5px; }

.memory-panel { margin-bottom: 18px; }

.memory-policy-list { display: grid; gap: 2px; }

.memory-policy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--border);
}

.memory-policy-row:last-child { border-bottom: 0; }
.memory-policy-row strong { display: block; font-size: 12.5px; }

/* Scoped to the description only: a bare `.memory-policy-row span` also hit the
   shared Switch track and knocked it out of alignment. */
.memory-policy-row > div > span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
}

.memory-turn-limit {
  width: 74px;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-family: inherit;
  font-size: 12px;
}

.memory-knowledge-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.memory-blocked {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--yellow) 30%, var(--border));
  border-radius: 10px;
  background: var(--yellow-soft);
  color: var(--yellow);
  font-size: 12px;
}

.memory-blocked i { width: 15px; height: 15px; flex: 0 0 15px; }

.memory-empty,
.memory-boot {
  padding: 26px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.memory-table td small { display: block; margin-top: 3px; color: var(--muted); }

.memory-row-actions { display: flex; align-items: center; gap: 2px; }

.memory-row-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  width: 26px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}

.memory-row-actions button:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface-soft);
}

.memory-row-actions i { width: 13px; height: 13px; }

.memory-create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px minmax(0, 2fr) minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.memory-create-form select,
.memory-create-form input {
  height: 36px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font-family: inherit;
  font-size: 12px;
}

.memory-entry-list { display: grid; gap: 9px; }

.memory-entry {
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.memory-entry.is-archived,
.memory-entry.is-rejected { opacity: 0.6; }

.memory-entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}

.memory-entry-head strong { font-size: 12.5px; }

.memory-entry-head em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.memory-entry-head small { margin-left: auto; color: var(--muted); font-size: 10.5px; }

.memory-entry p { margin: 0 0 10px; font-size: 12.5px; line-height: 1.6; }

.memory-entry footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 10.5px;
}

.memory-working-session {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.memory-working-session > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.memory-working-session header strong { display: block; font-size: 12.5px; }
.memory-working-session header small { display: block; margin-top: 2px; color: var(--muted); font-size: 10.5px; }

.memory-working-session ol { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }

.memory-working-session li {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface-soft);
}

.memory-working-session li.is-archived { opacity: 0.5; }

.memory-working-session li span {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.memory-working-session li p { margin: 0; font-size: 11.5px; line-height: 1.5; }

@media (max-width: 1100px) {
  .memory-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .memory-create-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .memory-kpi-grid { grid-template-columns: 1fr; }
  .memory-create-form { grid-template-columns: 1fr; }
  .memory-working-session li { grid-template-columns: 1fr; gap: 3px; }
}

/* SYD confirmation modal ----------------------------------------------------
   Destructive actions must state what disappears and what survives, in the
   product's own voice rather than the browser's. */

.syd-confirm-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgb(13 71 161 / 18%);
}

.syd-confirm-dialog::backdrop { background: rgb(15 23 42 / 34%); }

.syd-confirm-card { display: grid; gap: 14px; padding: 20px; }

/* An explicit display value beats the [hidden] attribute, so optional blocks
   must opt out of it deliberately. */
.syd-confirm-card [hidden] { display: none; }

.syd-confirm-head { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 13px; }

.syd-confirm-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  line-height: 0;
  background: var(--blue-soft);
  color: var(--brand-blue-dark);
}

.syd-confirm-icon.is-danger { background: var(--red-soft); color: var(--red); }
.syd-confirm-icon > svg { display: block; width: 18px; height: 18px; }

.syd-confirm-head h2 { margin: 0; font-size: 16px; }

.syd-confirm-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.syd-confirm-details {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 12px 13px;
  border-radius: 11px;
  background: var(--surface-soft);
  list-style: none;
}

.syd-confirm-details li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  font-size: 12px;
}

.syd-confirm-details span { color: var(--muted); }
.syd-confirm-details strong { text-align: right; overflow-wrap: anywhere; }

.syd-confirm-field { display: grid; gap: 6px; }

.syd-confirm-field span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.syd-confirm-field input {
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
}

.syd-confirm-field input:focus {
  outline: 0;
  border-color: var(--accent);
}

.syd-confirm-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.syd-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

.syd-confirm-actions .command-button.is-danger {
  background: var(--red);
  border-color: var(--red);
}

/* Run details: context breakdown -------------------------------------------
   Two distinct metrics. What the runtime reported, and what SYD built. */

.assistant-run-details {
  margin-top: 10px;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
}

.assistant-run-details > summary {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.assistant-run-details > summary::-webkit-details-marker { display: none; }
.assistant-run-details > summary::before { content: "▸ "; }
.assistant-run-details[open] > summary::before { content: "▾ "; }
.assistant-run-details > summary:hover { color: var(--text); }

.assistant-context-block { margin-top: 11px; }

.assistant-context-block > h4 {
  margin: 0 0 7px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.assistant-context-table { display: grid; gap: 3px; }

.assistant-context-table > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
  padding: 4px 0;
  font-size: 11.5px;
}

.assistant-context-table > div.is-muted { color: var(--muted); }

.assistant-context-table b {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  font-weight: 500;
}

.assistant-context-table small { display: block; color: var(--muted); font-size: 10px; }

.assistant-context-total {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-weight: 700;
}

.assistant-context-caveat {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.55;
}

/* A run held for approval is a state of its own: it is not working, and the
   decision that unblocks it lives in Agent Room > Approvals. */
.assistant-awaiting-approval {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line-strong));
  border-radius: 12px;
  background: var(--blue-soft);
}

.assistant-awaiting-approval > i {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--brand-blue-dark);
}

.assistant-awaiting-approval > div { flex: 1; min-width: 0; }

.assistant-awaiting-approval strong {
  display: block;
  color: var(--brand-blue-dark);
  font-size: 12px;
}

.assistant-awaiting-approval p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.assistant-run-compact.is-refused { color: #9a4b41; }


/* Between the wide desktop layout and the 720px wrap, the row now degrades in
   steps instead of clipping: the controls narrow, then the least ambiguous
   labels give way to their icons. Every control stays visible and clickable. */
@media (max-width: 1180px) {
  .assistant-control { max-width: 132px; }
  .assistant-advanced-toggle { font-size: 0; gap: 0; padding: 0 8px; }
  .assistant-advanced-toggle i { margin: 0; }
}

@media (max-width: 940px) {
  .assistant-control { max-width: 104px; }
}


/* ---------------------------------------------------------------------------
   Knowledge > Files — socle documentaire et retrieval
   Réutilise les blocs `panel` / `memory-panel` existants : seuls les objets
   propres au retrieval (résultat, chunk, source) reçoivent un style.
--------------------------------------------------------------------------- */

.knowledge-search-form { margin-bottom: 14px; }

.knowledge-results { display: grid; gap: 10px; }

.knowledge-result {
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.knowledge-result header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 7px;
}

.knowledge-result header strong { font-size: 12.5px; }

.knowledge-result code,
.knowledge-detail code,
.assistant-source-group code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-strong, rgba(127, 127, 127, 0.1));
  color: var(--muted);
  font-size: 11px;
}

.knowledge-result header em {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.knowledge-result p {
  margin: 0 0 9px;
  font-size: 12.5px;
  line-height: 1.65;
}

.knowledge-result footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11.5px;
}

.knowledge-result footer span { display: flex; align-items: center; gap: 6px; }
.knowledge-result footer i { width: 13px; height: 13px; }

.knowledge-create-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 12px;
}

.knowledge-create-form input,
.knowledge-create-form select,
.knowledge-create-form textarea {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font-family: inherit;
  font-size: 12px;
}

.knowledge-create-form input[name="title"] { grid-column: span 2; }
/* Project and source reference share one row: a lone control on a four-column
   grid reads as a mistake, not as a field. */
.knowledge-create-form input[name="source_ref"] { grid-column: span 3; }

.knowledge-create-form textarea {
  grid-column: span 4;
  height: auto;
  padding: 9px 10px;
  line-height: 1.6;
  resize: vertical;
}

.knowledge-create-form button { grid-column: span 4; justify-self: start; }

.knowledge-detail {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.knowledge-detail > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.knowledge-detail > header small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
}

.knowledge-chunks { margin: 0; padding: 0 0 0 4px; list-style: none; display: grid; gap: 10px; }

.knowledge-chunks li {
  padding: 10px 12px;
  border-left: 2px solid var(--border);
}

.knowledge-chunks header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 11.5px;
}

.knowledge-chunks header span { font-weight: 600; }
.knowledge-chunks header em { margin-left: auto; color: var(--muted); font-style: normal; font-size: 11px; }
.knowledge-chunks p { margin: 0; font-size: 12px; line-height: 1.6; white-space: pre-wrap; }

.memory-source-cell { display: flex; flex-wrap: wrap; gap: 4px; }

/* Sources dans Run details — références, jamais le contenu recopié. */
/* Grid items default to min-width:auto, so a long source label would push the
   row wider than the panel instead of ellipsising inside it. */
.assistant-sources { display: grid; gap: 11px; min-width: 0; }
.assistant-source-group { min-width: 0; }

.assistant-source-group header {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
}

.assistant-source-group header small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.assistant-source-group ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.assistant-source-group li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-size: 11.5px;
}

.assistant-source-group li > code,
.assistant-source-group li > em { flex: 0 0 auto; }

.assistant-source-group li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assistant-source-group li em { color: var(--muted); font-style: normal; font-size: 11px; }

@media (max-width: 900px) {
  .knowledge-create-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .knowledge-create-form input[name="title"],
  .knowledge-create-form input[name="source_ref"],
  .knowledge-create-form select[name="project_id"],
  .knowledge-create-form textarea,
  .knowledge-create-form button { grid-column: span 2; }
}


/* Files : la recherche second cerveau reste en tête de la bibliothèque. */
.knowledge-retrieval { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }

.knowledge-retrieval > label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.knowledge-retrieval i { width: 15px; height: 15px; color: var(--brand-blue, #0d47a1); }
.knowledge-retrieval input { width: 100%; padding: 0; border: 0; outline: 0; background: transparent; font-family: inherit; font-size: 12px; }

.knowledge-results-panel { display: grid; gap: 10px; }
.knowledge-file-detail { display: grid; gap: 14px; margin-top: 2px; }
.knowledge-file-detail code { padding: 1px 5px; background: var(--surface-soft, #f4f6f8); border-radius: 5px; font-size: 11px; }
.knowledge-file-detail > header > div:last-child { display: flex; align-items: center; gap: 10px; }

.syd-table tr.is-open { background: #eff6ff; }

@media (max-width: 760px) {
  .knowledge-retrieval { grid-template-columns: 1fr; }
}

/* Mission opérationnelle : une case explicite, jamais un effet de bord d'un
   message. Une Mission est un travail nommé, pas la trace de chaque tour. */
.assistant-mission-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  color: var(--text);
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}

.assistant-mission-toggle.is-active {
  color: var(--brand-blue, #0d47a1);
  border-color: var(--brand-blue, #0d47a1);
}

.assistant-mission-toggle input { accent-color: var(--brand-blue, #0d47a1); }

/* Téléphone (mesuré à 375 px) : le titre de la conversation prend sa propre ligne au lieu de
   s'écraser mot par mot contre les actions, et les choix de route tiennent sur une rangée
   qui défile au pouce au lieu de quatre rangées empilées au-dessus du message. */
@media (max-width: 640px) {
  .assistant-route-bar { flex-wrap: wrap; gap: 8px; }
  .assistant-route-identity { flex: 1 1 100%; }
  .assistant-route-identity > div { min-width: 0; }
  .assistant-route-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .assistant-composer-controls {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .assistant-composer-controls::-webkit-scrollbar { display: none; }
  .assistant-control, .assistant-advanced-toggle, .assistant-file-button { flex: none; height: 36px; }
  /* La rangée défile : chaque choix garde son libellé lisible au lieu de se réduire à une icône. */
  .assistant-control { max-width: none; }
  .assistant-control select { max-width: 150px; }
}
