/* Lucii — démo Kigali. Design EXACT du prototype (décision fondateur
   2026-08-01) : dégradé « wahoo » plein écran, surfaces verre, typo
   Plus Jakarta Sans pour titres/solde. Teintes clés : #011918 base ·
   #002F37 · #086483 · #117E94 · #1BA2AC primaire · #6EE5D8 accent. */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #011918;
  --surface: rgba(255, 255, 255, .07);
  --surface-2: rgba(1, 32, 36, .88);
  --line: rgba(255, 255, 255, .12);
  --primary: #1BA2AC;
  --accent: #6EE5D8;
  --deep: #086483;
  --text: #EAF7F5;
  --muted: rgba(255, 255, 255, .55);
  --danger: #E5766E;
  --ok: #58D6A0;
  --font-heading: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html, body { height: 100%; }
body {
  /* gradient-wahoo du prototype, fixé pour que chaque écran le partage */
  background: var(--bg) linear-gradient(160deg, #011918 0%, #002F37 30%, #086483 70%, #117E94 100%) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  overflow-x: clip; /* les anneaux du micro débordent du viewport étroit */
}
h1, h2, h3, .balance, .mic-label { font-family: var(--font-heading); }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; }
.screen { padding: 20px 20px 40px; min-height: 100dvh; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* --- Auth --- */
.auth-wrap { display: flex; flex-direction: column; justify-content: center; min-height: 90dvh; gap: 28px; }
.brand { text-align: center; }
.brand-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 8px 40px rgba(27,162,172,.35); }
.brand h1 { font-size: 34px; letter-spacing: .12em; margin-top: 12px; font-weight: 700; }
.tagline { color: var(--muted); margin-top: 4px; }
form { display: flex; flex-direction: column; gap: 14px; }
label span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input {
  width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 17px; outline: none;
}
input:focus { border-color: var(--primary); }
.demo-note { text-align: center; font-size: 12px; color: var(--muted); }

/* --- Boutons --- */
.btn {
  padding: 15px 18px; border-radius: 14px; border: none; font-size: 16px; font-weight: 600;
  cursor: pointer; transition: transform .06s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--deep)); color: #fff; }
.btn.primary:disabled { opacity: .5; }
.btn.ghost { background: none; color: var(--accent); }
.btn.big { width: 100%; margin-top: 24px; }
.chip {
  background: var(--surface); border: 1px solid var(--line); color: var(--accent);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}

/* --- Accueil (layout du prototype : logo → solde → micro → actions) --- */
.home-head { position: relative; display: flex; justify-content: center; align-items: center; margin-bottom: 18px; }
.brand-letters { height: 30px; object-fit: contain; }
.home-head .chip { position: absolute; right: 0; }
.msisdn { color: var(--muted); font-size: 13px; }
.balance-head { text-align: center; }
.balance-cur { font-size: 15px; color: rgba(255, 255, 255, .9); font-weight: 500; }
.balance { font-size: 46px; font-weight: 700; margin: 6px 0 10px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: #fff; }
.balance .cur { font-size: 20px; color: rgba(255, 255, 255, .85); font-weight: 600; }
.accounts-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .15); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: 999px; padding: 7px 16px; font-size: 12px; font-weight: 500; color: rgba(255, 255, 255, .9);
}

/* Actions circulaires en bas de l'accueil (style JabuPay du prototype). */
.actions { display: flex; justify-content: center; gap: 22px; margin: 14px 0 10px; }
.action {
  background: none; border: none; color: rgba(255, 255, 255, .85);
  font-size: 12px; font-weight: 500; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
}
.action:active { transform: scale(.95); }
.action .ico {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255, 255, 255, .10); border: 1px solid rgba(255, 255, 255, .20);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: #fff; display: grid; place-items: center;
}

/* --- Transactions --- */
.tx-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.tx {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 13px 15px;
}
.tx .who { font-size: 15px; font-weight: 600; }
.tx .what { font-size: 12px; color: var(--muted); }
.tx .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx .amt.in { color: var(--ok); }
.tx .amt.out { color: var(--text); }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; font-size: 14px; }

/* --- Sous-écrans --- */
.sub-head { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.sub-head h2 { font-size: 20px; }
.back {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  width: 38px; height: 38px; border-radius: 12px; font-size: 22px; cursor: pointer; line-height: 1;
}
.op-sub { color: var(--muted); margin: -10px 0 18px; font-size: 14px; }
.amount-box {
  display: flex; align-items: baseline; gap: 10px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px; padding: 8px 18px; margin-bottom: 14px;
}
.amount-box input { border: none; background: none; font-size: 40px; font-weight: 700; padding: 8px 0; }
.amount-box .cur { color: var(--accent); font-weight: 700; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick button {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  color: var(--accent); padding: 10px 4px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.limits-note { color: var(--muted); font-size: 12px; margin-top: 14px; }
.field { display: block; margin-bottom: 14px; }

/* --- Audit --- */
.audit-badge {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 14px;
  font-weight: 700; margin-bottom: 14px; border: 1px solid var(--line);
}
.audit-badge.ok { background: rgba(88,214,160,.1); color: var(--ok); }
.audit-badge.ko { background: rgba(229,118,110,.12); color: var(--danger); }
.audit-limits { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.audit-limits div {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.audit-limits b { display: block; font-size: 15px; }
.audit-limits span { font-size: 11px; color: var(--muted); }
.audit-explain { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.audit-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.audit-rec {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; font-size: 11.5px;
}
.audit-rec .l1 { display: flex; justify-content: space-between; gap: 8px; }
.audit-rec .act { color: var(--accent); font-weight: 700; }
.audit-rec .dec-ok { color: var(--ok); }
.audit-rec .dec-refused { color: var(--danger); }
.audit-rec .hash { color: var(--muted); word-break: break-all; margin-top: 3px; }

/* --- Modale --- */
.modal {
  position: fixed; inset: 0; background: rgba(0, 10, 10, .7); backdrop-filter: blur(6px);
  display: grid; place-items: end center; z-index: 50;
}
.modal-card {
  background: var(--surface-2); border: 1px solid var(--line); width: 100%; max-width: 480px;
  border-radius: 26px 26px 0 0; padding: 30px 24px calc(30px + env(safe-area-inset-bottom));
  text-align: center; animation: up .22s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-icon { font-size: 46px; margin-bottom: 10px; }
.modal-icon .spinner {
  width: 52px; height: 52px; margin: 0 auto; border-radius: 50%;
  border: 4px solid rgba(110,229,216,.2); border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.modal-card h3 { font-size: 19px; margin-bottom: 6px; }
.modal-card p { color: var(--muted); font-size: 14.5px; white-space: pre-line; overflow-wrap: anywhere; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }

/* --- Toast --- */
.toast {
  position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 14px; font-size: 14px; z-index: 60; max-width: 90vw;
  box-shadow: 0 6px 30px rgba(0,0,0,.4);
}
.toast.err { border-color: rgba(229,118,110,.5); }

/* hidden doit TOUJOURS gagner (sinon display:grid/flex le neutralise et un
   élément invisible intercepte les clics). */
[hidden] { display: none !important; }

/* --- Biométrie vocale --- */
.voice-banner {
  display: flex; align-items: center; gap: 12px; width: 100%;
  margin-top: 14px; padding: 14px 16px; text-align: left;
  background: linear-gradient(120deg, rgba(27,162,172,.25), rgba(8,100,131,.18));
  border: 1px solid var(--primary); border-radius: 16px; color: var(--text);
  font: inherit; cursor: pointer;
}
.voice-banner .ico { font-size: 22px; }
.voice-banner-text b { display: block; }
.voice-banner-text small { color: var(--muted); }
.voice-banner.enrolled {
  background: var(--surface); border-color: var(--line);
}
.voice-banner.enrolled .voice-banner-text b { color: var(--ok); }
.voice-card {
  margin-top: 18px; padding: 22px 18px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 18px; text-align: center;
  display: flex; flex-direction: column; gap: 16px;
}
.voice-step-label { color: var(--muted); font-size: 14px; }
.voice-phrase { font-size: 20px; font-weight: 600; color: var(--accent); min-height: 58px; }

/* --- Factures & fournisseurs --- */
.action { position: relative; }
.action .badge {
  position: absolute; top: -4px; right: -2px; min-width: 18px; height: 18px;
  border-radius: 9px; background: #e0483e; color: #fff; font-size: 11px;
  font-weight: 700; display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}
.bills-list { list-style: none; margin: 18px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.bill {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 13px 15px;
}
.bill .info { flex: 1; min-width: 0; }
.bill .who { font-size: 15px; font-weight: 600; }
.bill .what { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.bill .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bill .btn.pay { padding: 8px 14px; font-size: 13px; border-radius: 10px; width: auto; }
.bill .paid-chip {
  font-size: 12px; font-weight: 700; color: var(--ok); white-space: nowrap;
}

/* --- Bouton micro « Dis Lucii » (HeroMicButton du prototype, à l'identique) ---
   L'accueil est dédié au micro : la section occupe TOUT l'espace entre le
   solde et les actions, le bouton est l'orbe central (33vh, borné 180-280px),
   dôme radial turquoise + anneaux SONAR au repos, dôme rouge + anneaux
   magiques en session. */
#screen-home {
  display: flex; flex-direction: column;
  padding-bottom: calc(88px + env(safe-area-inset-bottom)); /* nav basse fixe */
}
.mic-hero {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  justify-content: center; flex: 1; min-height: 260px; margin: 10px 0 0;
}
.mic-stage {
  position: relative; display: grid; place-items: center; margin-bottom: 22px;
  width: clamp(180px, 33vh, 280px); height: clamp(180px, 33vh, 280px);
}
.mic-btn {
  position: relative; z-index: 2; width: 100%; height: 100%; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .15); cursor: pointer; display: grid; place-items: center;
  background: radial-gradient(circle, #22d3b8 0%, #1BA2AC 40%, #086483 70%, #003540 100%);
  box-shadow: 0 0 80px rgba(34, 211, 184, .45), 0 0 140px rgba(27, 162, 172, .2),
    inset 0 -4px 20px rgba(0, 0, 0, .2), 0 0 0 2px rgba(255, 255, 255, .2);
  transition: background .5s ease, box-shadow .5s ease, transform .06s ease;
}
.mic-btn:active { transform: scale(.95); }
.mic-btn svg.ico-mic { width: 40%; height: 40%; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .35)); }
.mic-btn svg.ico-stop { width: 26%; height: 26%; }
.mic-btn .ico-stop { display: none; }
.mic-hero.active .mic-btn {
  border: none;
  background: radial-gradient(circle at 50% 38%, #f4a090 0%, #e8796a 18%, #d4574a 38%, #b83a30 65%, #8c2a22 100%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45), 0 4px 16px rgba(0, 0, 0, .25), 0 0 60px rgba(192, 57, 43, .2),
    inset 0 8px 30px rgba(255, 220, 210, .35), inset 0 -10px 30px rgba(60, 12, 8, .45);
}
.mic-hero.active .mic-btn .ico-mic { display: none; }
.mic-hero.active .mic-btn .ico-stop { display: block; }
/* Anneaux SONAR au repos (sonar-ring du prototype : expansion 1→2.2 + fondu,
   décalés d'1 s). Masqués pendant la session (les anneaux magiques prennent
   le relais). */
.mic-sonar {
  position: absolute; inset: 0; display: grid; place-items: center;
  pointer-events: none; z-index: 1;
}
.mic-sonar i {
  position: absolute; inset: 0; border-radius: 50%;
  animation: sonar-ring 3s ease-out infinite;
  will-change: transform, opacity;
}
.mic-sonar i:nth-child(1) { border: 2px solid rgba(34, 211, 184, .35); }
.mic-sonar i:nth-child(2) { border: 2px solid rgba(34, 211, 184, .25); animation-delay: 1s; }
.mic-sonar i:nth-child(3) { border: 1px solid rgba(34, 211, 184, .15); animation-delay: 2s; }
.mic-hero.active .mic-sonar { display: none; }
@keyframes sonar-ring {
  0% { transform: scale(1); opacity: .4; }
  100% { transform: scale(2.2); opacity: 0; }
}
/* Anneaux concentriques pulsés (CSSMagicRings du prototype), visibles pendant
   la session. Interpolation teal #2bbcb3 → bleu #0ea5e9, opacité décroissante. */
.mic-rings {
  position: absolute; inset: 0; display: grid; place-items: center;
  pointer-events: none; opacity: 0; transition: opacity .3s ease-in-out;
}
.mic-hero.active .mic-rings { opacity: 1; }
.mic-rings i {
  position: absolute; border-radius: 50%;
  animation: magic-ring-pulse 3s ease-in-out infinite;
  will-change: transform, opacity;
}
/* Tailles relatives à l'orbe (l'orbe est désormais fluide 180-280px). */
.mic-rings i:nth-child(1) { width: 113%; height: 113%; border: 2px solid rgba(43, 188, 179, .50); box-shadow: 0 0 10px rgba(43, 188, 179, .20); }
.mic-rings i:nth-child(2) { width: 139%; height: 139%; border: 1px solid rgba(36, 182, 193, .42); box-shadow: 0 0 16px rgba(36, 182, 193, .17); animation-delay: .5s; }
.mic-rings i:nth-child(3) { width: 165%; height: 165%; border: 1px solid rgba(29, 177, 206, .34); box-shadow: 0 0 22px rgba(29, 177, 206, .14); animation-delay: 1s; }
.mic-rings i:nth-child(4) { width: 191%; height: 191%; border: 1px solid rgba(21, 171, 220, .26); box-shadow: 0 0 28px rgba(21, 171, 220, .10); animation-delay: 1.5s; }
.mic-rings i:nth-child(5) { width: 217%; height: 217%; border: 1px solid rgba(14, 165, 233, .18); box-shadow: 0 0 34px rgba(14, 165, 233, .07); animation-delay: 2s; }
@keyframes magic-ring-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.08); opacity: .5; } }
.mic-label { font-weight: 700; font-size: 19px; }
.mic-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
@media (prefers-reduced-motion: reduce) {
  .mic-btn, .mic-rings i, .mic-sonar i { animation: none !important; }
}

/* --- Navigation basse (3 onglets, design prototype) --- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 480px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(1, 25, 24, .72);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid rgba(255, 255, 255, .08);
  transition: transform .3s ease;
}
/* La nav s'efface pendant une session assistant (comme le prototype). */
body.ai-active .bottom-nav { transform: translateY(110%); }
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer; padding: 6px 0;
  color: rgba(255, 255, 255, .4); font-size: 10px; line-height: 1.2; font-weight: 400;
}
.nav-item svg { stroke: currentColor; }
.nav-item.active { color: #1BA2AC; font-weight: 600; }
.nav-item.active svg { filter: drop-shadow(0 0 6px rgba(27, 162, 172, .5)); }
/* La nav réserve sa hauteur en bas de chaque écran une fois connecté. */
body.authed .screen { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

/* --- Onglets Activity / Profil --- */
.tab-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.tab-head h2 { font-size: 22px; }
.profile-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 22px;
  padding: 20px; margin-bottom: 4px;
}
.avatar {
  width: 60px; height: 60px; border-radius: 50%; flex: none;
  background: rgba(27, 162, 172, .18); color: var(--accent);
  display: grid; place-items: center; font-size: 22px; font-weight: 700;
}
.profile-name { font-size: 18px; font-weight: 600; }
.voice-banner.plain { background: var(--surface); border-color: var(--line); }
.btn-logout {
  width: 100%; margin-top: 18px; padding: 15px; border-radius: 16px;
  background: none; border: 1px solid rgba(229, 118, 110, .4);
  color: var(--danger); font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
}
.btn-logout:active { transform: scale(.98); }

/* --- Assistant conversationnel (ai.js) --- */
.ai-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface-2); border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .35);
}
.ai-head { display: flex; align-items: center; gap: 10px; }
.ai-head #ai-status { flex: 1; color: var(--muted); font-size: 14px; }
.ai-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); animation: ai-pulse 1.6s ease-in-out infinite;
}
.ai-panel.speaking .ai-dot { background: var(--ok); }
@keyframes ai-pulse { 50% { opacity: .35; } }
/* Retour porteur 2026-07-31 (note dictée) : le fil écrit reste alimenté (il
   nourrit la télémétrie /v1/ai/logs) mais n'est PLUS affiché à l'écran. */
.ai-transcript { display: none; }
.ai-line { margin: 4px 0; font-size: 14px; line-height: 1.35; }
.ai-line.user { color: var(--accent); }
.ai-line.user::before { content: '› '; }
.ai-line.assistant { color: var(--text); }
.ai-note { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.ai-panel img { image-rendering: pixelated; }
