:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --user: #2563eb;
  --bot: #334155;
  --danger: #ef4444;
}
* { box-sizing: border-box; }
/* l'attribut hidden doit l'emporter sur les display:grid/flex ci-dessous */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 17px;
}

/* --- Connexion --- */
.login { display: grid; place-items: center; height: 100%; padding: 20px; }
.login-card {
  background: var(--panel); border-radius: 16px; padding: 32px;
  width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.subtitle { color: var(--muted); margin: 0 0 24px; }
form label { display: block; margin-bottom: 16px; font-size: 15px; color: var(--muted); }
input, textarea {
  width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--panel-2); background: #0b1220; color: var(--text);
  font-size: 16px; font-family: inherit;
}
button {
  background: var(--accent); color: white; border: 0; border-radius: 10px;
  padding: 12px 18px; font-size: 16px; cursor: pointer; font-weight: 600;
}
button:hover { background: var(--accent-2); }
button.ghost { background: transparent; border: 1px solid var(--panel-2); color: var(--muted); font-weight: 500; padding: 8px 14px; }
button:disabled { opacity: .5; cursor: default; }
.error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }

/* --- Application : barre latérale + chat --- */
.app { display: flex; height: 100%; }

.sidebar {
  width: 280px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--panel-2); display: flex; flex-direction: column;
}
.sidebar-head { padding: 14px; }
.new-btn { width: 100%; }
.conv-list { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 0 8px; }
.conv-item {
  display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-radius: 10px;
  cursor: pointer; color: var(--text); font-size: 15px;
}
.conv-item:hover { background: var(--panel-2); }
.conv-item.active { background: var(--panel-2); }
.conv-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-del {
  background: transparent; color: var(--muted); border: 0; font-size: 20px; line-height: 1;
  padding: 0 4px; opacity: 0; cursor: pointer; font-weight: 400;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: var(--danger); background: transparent; }
.sidebar-foot {
  padding: 14px; border-top: 1px solid var(--panel-2);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px;
}
.sidebar-foot #who { font-weight: 600; }
.sidebar-foot .ghost { margin-left: auto; }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mobilebar {
  display: none; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--panel); border-bottom: 1px solid var(--panel-2);
}
.pill { background: var(--panel-2); color: var(--text); border-radius: 999px; padding: 3px 12px; font-size: 13px; }

.messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 760px; padding: 14px 18px; border-radius: 16px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--user); color: white; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--bot); border-bottom-left-radius: 4px; }
.msg.note { align-self: flex-start; background: transparent; color: var(--muted); font-size: 14px; font-style: italic; padding: 2px 8px; }
.welcome { color: var(--muted); text-align: center; margin: auto; max-width: 520px; line-height: 1.6; }

/* --- Bandeau d'activité (actions de Claude, séparées du fil) --- */
.activity { background: #172033; border-top: 1px solid var(--panel-2); }
.activity-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: transparent; border: 0; color: var(--muted); padding: 10px 20px;
  font-size: 14px; font-weight: 500; cursor: pointer; border-radius: 0;
}
.activity-head:hover { background: rgba(255,255,255,.03); }
.activity-head-left { display: inline-flex; align-items: center; gap: 8px; }
.activity-log { max-height: 120px; overflow-y: auto; padding: 0 20px 12px; font-size: 13px; color: var(--muted); }
.act-line { padding: 3px 0; white-space: pre-wrap; word-wrap: break-word; }
.activity.collapsed .activity-log { display: none; }
.chev { transition: transform .15s ease; }
.activity.collapsed .chev { transform: rotate(-90deg); }
.spinner {
  display: none; width: 13px; height: 13px; border: 2px solid var(--panel-2);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
}
.activity.working .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* état « en cours » vs « terminé » */
.activity.working { border-left: 3px solid var(--accent); }
.activity.working #activity-label { color: var(--text); }
.activity.done { background: #0e2a1c; border-left: 3px solid #22c55e; }
.activity.done #activity-label { color: #4ade80; font-weight: 700; }
.activity.done { animation: doneflash .5s ease; }
@keyframes doneflash { from { background: #14532d; } to { background: #0e2a1c; } }

.composer { display: flex; gap: 10px; padding: 16px 20px; background: var(--panel); border-top: 1px solid var(--panel-2); }
.composer textarea { flex: 1; resize: none; max-height: 160px; margin: 0; }
.composer button { align-self: flex-end; }

.typing { display: inline-flex; gap: 4px; }
.typing span { width: 7px; height: 7px; background: var(--muted); border-radius: 50%; animation: blink 1.2s infinite both; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2 } 40% { opacity: 1 } }

/* --- Mobile : la barre latérale devient un tiroir --- */
@media (max-width: 720px) {
  body { font-size: 16px; }
  .mobilebar { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 20;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  .sidebar.open { transform: translateX(0); }
  .messages { padding: 16px; }
}
