* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #12101a;
  --bg-soft: #1b1826;
  --bg-input: #241f33;
  --border: #2f2942;
  --text: #efeaf6;
  --text-dim: #9a90b0;
  --accent: #c2559e;
  --accent-2: #7b5cd6;
  --bubble-user: linear-gradient(135deg, #7b5cd6, #c2559e);
  --bubble-amizo: #241f33;
  --radius: 18px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ── Avatar ─────────────────────────────────────────────── */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c2559e, #7b5cd6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: #fff;
  flex-shrink: 0;
}
.avatar-lg { width: 72px; height: 72px; font-size: 32px; margin: 0 auto 16px; }

/* ── Login ──────────────────────────────────────────────── */
.login-page {
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at top, #241f33, var(--bg));
}
.login-card {
  text-align: center;
  padding: 48px 40px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 24px;
  width: min(360px, 90vw);
}
.login-card h1 { font-size: 28px; margin-bottom: 4px; }
.subtitle { color: var(--text-dim); font-size: 14px; margin-bottom: 28px; }
.login-card input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
  outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--bubble-user);
  color: #fff;
  font-size: 16px; font-weight: 600;
  cursor: pointer;
}
.error { color: #ff7b9c; font-size: 14px; margin-top: 12px; }

/* ── Layout appli ───────────────────────────────────────── */
.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 860px;
  margin: 0 auto;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.identity { display: flex; align-items: center; gap: 12px; }
.name { font-weight: 700; font-size: 17px; }
.status { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #4cd47a; display: inline-block; }

.actions { display: flex; align-items: center; gap: 8px; }
.actions select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
}
.icon-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 15px;
  cursor: pointer;
  color: var(--text);
}
.icon-btn:hover { border-color: var(--accent); }

/* ── Chat ───────────────────────────────────────────────── */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: var(--radius);
  line-height: 1.45;
  font-size: 15px;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: pop .15s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }

.msg.user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.amizo {
  align-self: flex-start;
  background: var(--bubble-amizo);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}
.msg .action {
  font-style: italic;
  color: #d98cc0;
  opacity: .9;
}
.msg.user .action { color: #ffd6ef; }

.msg.big-emoji {
  font-size: 38px;
  line-height: 1.15;
  background: none;
  border: none;
  padding: 2px 6px;
}

.msg.error-msg {
  align-self: center;
  background: #3a1e2a;
  border: 1px solid #6e2c47;
  color: #ffb3c7;
  font-size: 13px;
}

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

.welcome {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  margin: auto;
  padding: 40px 20px;
}
.welcome .avatar-lg { margin-bottom: 12px; }

/* ── Composer ───────────────────────────────────────────── */
.composer {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 15px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  max-height: 140px;
}
.composer textarea:focus { border-color: var(--accent); }
.send-btn {
  width: 44px; height: 44px;
  border: none; border-radius: 50%;
  background: var(--bubble-user);
  color: #fff; font-size: 17px;
  cursor: pointer;
  flex-shrink: 0;
}
.send-btn:disabled { opacity: .5; cursor: default; }

/* ── Panneau mémoire ────────────────────────────────────── */
.side-panel[hidden] { display: none; }

.side-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(380px, 100vw);
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
  padding: 20px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 40px rgba(0, 0, 0, .5);
}
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel-header h2 { font-size: 17px; }
.panel-hint { font-size: 13px; color: var(--text-dim); margin-bottom: 16px; }
.panel-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.panel-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}
.panel-list button {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 14px;
}
.panel-list button:hover { color: #ff7b9c; }
.panel-form { display: flex; gap: 8px; margin-top: 14px; }
.panel-form input {
  flex: 1;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.panel-form button {
  width: 42px;
  border: none; border-radius: 10px;
  background: var(--bubble-user);
  color: #fff; font-size: 18px;
  cursor: pointer;
}

/* ── Face ID sur la page de connexion ───────────────────── */
.faceid-btn {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: rgba(194, 85, 158, .12);
  color: var(--text);
  font-size: 16px; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.faceid-btn:hover { background: rgba(194, 85, 158, .22); }
.faceid-btn:disabled { opacity: .6; cursor: default; }
.faceid-icon {
  font-size: 20px;
  border: 2px solid currentColor;
  border-radius: 7px;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.separator {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-dim); font-size: 12px;
  margin: 18px 0;
}
.separator::before, .separator::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.lock-note { color: var(--text-dim); font-size: 12px; margin-top: 16px; }

/* ── Panneau sécurité ───────────────────────────────────── */
.status-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.status-list li {
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
}
.status-list li.ok { color: #8be2a8; border-color: #2c5a3d; }
.status-list li.warn { color: #ffcf8b; border-color: #6b5324; }

.panel-sub {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
  margin: 20px 0 8px;
}
.side-panel .panel-list { flex: 0 1 auto; max-height: 180px; }
.wide-btn {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.wide-btn:hover { border-color: var(--accent); }
.wide-btn.danger { color: #ff9db6; border-color: #6e2c47; }
.wide-btn.danger:hover { background: #3a1e2a; }
.panel-spacer { flex: 1; }

/* ── Bandeau hors ligne ─────────────────────────────────── */
.offline-banner {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 20;
  background: #4a3a1e;
  color: #ffd79a;
  text-align: center;
  font-size: 13px;
  padding: 8px 12px;
  border-bottom: 1px solid #6b5324;
}
.offline-banner[hidden] { display: none; }

/* display:flex écrase l'attribut hidden — on le rétablit explicitement */
.faceid-btn[hidden], .separator[hidden], .panel-hint[hidden],
.error[hidden], .lock-note[hidden] { display: none !important; }
