:root {
  --bg: #070908;
  --panel: #0d100e;
  --panel-soft: #121713;
  --text: #f4f7f4;
  --muted: #879089;
  --line: rgba(255, 255, 255, 0.1);
  /* Réglés à l'exécution depuis /api/agent/appearance. Les valeurs ici sont
     le repli si l'appel échoue : l'assistant s'affiche toujours. */
  --green: #20d66b;
  --accent: var(--green);
  --accent-ink: #031107;
  --accent-on-dark: var(--green);
  --accent-soft: rgba(32, 214, 107, .12);
  --accent-border: rgba(32, 214, 107, .35);
  --radius: 8px;
  --yellow: #f5cf00;
  --orange: #ff7a00;
  --blue: #0b9ee5;
  --heading: "Oswald", sans-serif;
  --body: "Inter", sans-serif;
}

* { box-sizing: border-box; }

html, body { width: 100%; min-height: 100%; margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); }

body { min-height: 100dvh; }

button, textarea { font: inherit; }

button { color: inherit; }

.agent-shell {
  width: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(220px, 1fr) auto auto auto auto;
  background: var(--bg);
  overflow: hidden;
}

.agent-head {
  min-height: 74px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
}

.agent-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.agent-brand img { width: 42px; height: 42px; object-fit: contain; }
.agent-brand div { display: grid; gap: 5px; min-width: 0; }
.agent-brand strong { font-family: var(--heading); font-size: 16px; letter-spacing: 0; text-transform: uppercase; white-space: nowrap; }
.agent-brand span { color: var(--muted); font-size: 11px; display: flex; align-items: center; gap: 6px; }
.agent-brand i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent-border); }

.agent-head-actions { display: flex; gap: 6px; }
.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.icon-button:hover { border-color: rgba(255,255,255,.25); background: rgba(255,255,255,.04); }
.icon-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.progress-strip { padding: 12px 18px 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
.progress-strip > div { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.progress-strip span, .progress-strip strong { color: var(--muted); font-family: var(--heading); font-size: 10px; font-weight: 600; text-transform: uppercase; }
.progress-strip strong { color: var(--accent-on-dark); }
.progress-track { display: block; height: 2px; background: rgba(255,255,255,.08); overflow: hidden; }
.progress-track i { display: block; width: 0; height: 100%; background: var(--accent-on-dark); transition: width .3s ease; }

.messages { overflow-y: auto; padding: 22px 18px 12px; display: flex; flex-direction: column; gap: 13px; scroll-behavior: smooth; }
.message { max-width: 86%; display: grid; gap: 5px; animation: reveal .2s ease-out; }
.message p { margin: 0; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.message time { color: #626a64; font-size: 9px; text-transform: uppercase; }
.message.assistant { align-self: flex-start; }
.message.assistant p { background: var(--panel-soft); border-left-color: var(--accent-border); }
.message.user { align-self: flex-end; justify-items: end; }
.message.user p { background: rgba(11, 158, 229, .11); border-color: rgba(11, 158, 229, .25); }

.typing { margin: 0 18px 10px; width: 54px; height: 32px; border: 1px solid var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; gap: 4px; background: var(--panel-soft); }
.typing[hidden] { display: none; }
.typing i { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); animation: pulse 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

.project-summary { margin: 0 18px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.summary-head { min-height: 34px; display: flex; align-items: center; justify-content: space-between; padding: 0 11px; border-bottom: 1px solid var(--line); }
.summary-head span { color: var(--muted); font-family: var(--heading); font-size: 10px; text-transform: uppercase; }
.summary-head button { border: 0; background: none; color: var(--accent-on-dark); font-size: 10px; cursor: pointer; }
.summary-content { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; }
.summary-content span { border: 1px solid var(--line); border-radius: 4px; padding: 5px 7px; color: #c7cec8; font-size: 10px; }
.project-summary.collapsed .summary-content { display: none; }
.project-summary.collapsed .summary-head { border-bottom: 0; }

.quick-actions { display: flex; gap: 7px; padding: 0 18px 10px; overflow-x: auto; }
.quick-actions:empty { display: none; }
.quick-actions button, .quick-actions a {
  flex: 0 0 auto;
  min-height: 32px;
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-on-dark);
  padding: 7px 10px;
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.quick-actions button[data-action="confirm"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.quick-actions button:hover, .quick-actions a:hover { filter: brightness(1.15); }

.composer { margin: 0 18px; min-height: 52px; display: grid; grid-template-columns: minmax(0, 1fr) 40px; align-items: end; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 7px; }
.composer:focus-within { border-color: var(--accent-border); }
.composer textarea { width: 100%; min-height: 36px; max-height: 120px; resize: none; border: 0; outline: 0; background: transparent; color: var(--text); padding: 8px 7px; font-size: 13px; line-height: 1.45; }
.composer textarea::placeholder { color: #606862; }
.composer input[name="website"] { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }
.send-button { width: 40px; height: 38px; border: 0; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; }
.send-button:disabled { opacity: .45; cursor: wait; }
.send-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.privacy-copy { margin: 8px 18px 12px; color: #606862; font-size: 9px; text-align: center; line-height: 1.4; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@keyframes reveal { from { opacity: 0; transform: translateY(5px); } }
@keyframes pulse { 0%, 70%, 100% { opacity: .35; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }

@media (max-width: 420px) {
  .agent-head { padding-inline: 14px; }
  .messages { padding-inline: 14px; }
  .project-summary, .composer { margin-inline: 14px; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-inline: 14px; overflow: visible; }
  .quick-actions:not(:empty) { display: grid; }
  .quick-actions button, .quick-actions a { width: 100%; min-height: 38px; display: grid; place-items: center; text-align: center; white-space: normal; }
  .privacy-copy { margin-inline: 14px; }
  .message { max-width: 91%; }
}
