:root {
  --fond: #05070d;
  --fond-2: #0c111c;
  --ligne: #1c2536;
  --texte: #e6edf7;
  --discret: #8592a8;
  --accent: #39c6ff;
  --accent-2: #7b61ff;
  --ambre: #ffb020;
  --rouge: #ff5468;
  --vert: #35d39a;
  --rayon: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(120% 80% at 50% 30%, #0b1324 0%, var(--fond) 60%);
  color: var(--texte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

[hidden] { display: none !important; }

.ecran {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* --- appairage --- */
#appairage { justify-content: center; align-items: center; padding: 24px; }
.carte {
  background: color-mix(in srgb, var(--fond-2) 92%, transparent);
  border: 1px solid var(--ligne);
  border-radius: var(--rayon);
  padding: 24px;
  width: min(420px, 100%);
}
.carte h1 { margin: 0 0 8px; font-weight: 600; letter-spacing: .04em; }
.carte p { color: var(--discret); margin: 0 0 16px; }
code { background: #111a2b; padding: 2px 6px; border-radius: 6px; color: var(--texte); }
label { display: block; font-size: 14px; color: var(--discret); margin-bottom: 12px; }
input {
  display: block; width: 100%; margin-top: 6px;
  background: #0a0f19; color: var(--texte);
  border: 1px solid var(--ligne); border-radius: 12px;
  padding: 12px 14px; font-size: 17px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#code { letter-spacing: .25em; text-transform: uppercase; font-family: ui-monospace, monospace; }

button {
  font: inherit; color: #031018; background: var(--accent);
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600; cursor: pointer;
}
button.secondaire { background: #172033; color: var(--texte); }
button.danger { background: transparent; color: var(--rouge); border: 1px solid #4a1d27; }
button.large { width: 100%; margin-top: 8px; }
button.icone { background: transparent; color: var(--texte); font-size: 20px; padding: 6px 10px; }
.erreur { color: var(--rouge) !important; min-height: 1.4em; margin-top: 10px !important; }

/* --- application --- */
.barre {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid #0f1624;
}
.pastille { width: 9px; height: 9px; border-radius: 50%; background: var(--rouge); box-shadow: 0 0 8px currentColor; }
.pastille.ok { background: var(--vert); }
.cerveau { flex: 1; color: var(--discret); font-size: 14px; letter-spacing: .02em; }

#conversation {
  flex: 1 1 auto; overflow-y: auto; padding: 12px 16px 8px;
  display: flex; flex-direction: column; gap: 8px;
  max-height: 38vh;
  mask-image: linear-gradient(to bottom, transparent 0, #000 24px);
}
.bulle { max-width: 86%; padding: 9px 13px; border-radius: 16px; font-size: 15px; white-space: pre-wrap; }
.bulle.moi { align-self: flex-end; background: #13233a; border-bottom-right-radius: 5px; }
.bulle.jarvis { align-self: flex-start; background: #0f1828; border: 1px solid #16223a; border-bottom-left-radius: 5px; }
.bulle.info { align-self: center; background: transparent; color: var(--discret); font-size: 13px; padding: 2px; }

.scene { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 240px; }
#orbe { width: min(70vw, 320px); height: min(70vw, 320px); }
.etat { color: var(--discret); margin: 4px 0 0; font-size: 15px; letter-spacing: .03em; min-height: 1.4em; }

.commandes {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.saisie { flex: 1; }
.saisie input { margin: 0; border-radius: 999px; padding: 12px 18px; }
.parler {
  width: 76px; height: 76px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #6fe0ff, var(--accent) 45%, #1279b8);
  box-shadow: 0 0 0 6px #0f2436, 0 8px 30px #0aa0ff55;
  touch-action: none; user-select: none; -webkit-user-select: none;
  transition: transform .12s ease, box-shadow .2s ease;
}
.parler svg { width: 34px; height: 34px; fill: #04121c; }
.parler.actif { transform: scale(1.08); box-shadow: 0 0 0 10px #12324a, 0 0 40px #39c6ffaa; }
.parler.verrou { background: radial-gradient(circle at 35% 30%, #ff9aa8, var(--rouge) 50%, #a3182b); }

/* --- confirmation --- */
.voile {
  position: fixed; inset: 0; background: #000a; backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px; z-index: 10;
}
.confirmation { border-color: #5a4210; box-shadow: 0 0 40px #ffb02033; }
.sur-titre { color: var(--ambre) !important; font-size: 13px; text-transform: uppercase; letter-spacing: .12em; margin-bottom: 6px !important; }
#question { color: var(--texte) !important; font-size: 18px; }
.boutons { display: flex; gap: 12px; }
.boutons button { flex: 1; padding: 14px; font-size: 17px; }
#oui { background: var(--ambre); }
.aide { font-size: 13px; margin: 12px 0 0 !important; }

/* --- panneau --- */
.panneau {
  position: fixed; inset: 0 0 0 auto; width: min(380px, 92vw);
  background: var(--fond-2); border-left: 1px solid var(--ligne);
  padding: calc(16px + env(safe-area-inset-top)) 18px 24px; overflow-y: auto; z-index: 5;
  box-shadow: -20px 0 60px #000a;
}
.panneau-tete { display: flex; justify-content: space-between; align-items: center; }
.panneau h2 { margin: 0; font-weight: 600; }
.panneau h3 { margin: 22px 0 8px; font-size: 13px; color: var(--discret); text-transform: uppercase; letter-spacing: .12em; }
.liste { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.liste li { min-width: 0; background: #0a101b; border: 1px solid var(--ligne); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.liste .ligne { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.liste .ligne strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liste .etiquette { flex: none; }
.liste .sous { color: var(--discret); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jauge { height: 4px; background: #172033; border-radius: 4px; margin-top: 6px; overflow: hidden; }
.jauge > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.discret { color: var(--discret); font-size: 14px; }
.etiquette { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: #172033; color: var(--discret); }
.etiquette.vert { background: #0f2c22; color: var(--vert); }
.etiquette.ambre { background: #2e2410; color: var(--ambre); }

@media (prefers-reduced-motion: reduce) {
  .parler { transition: none; }
}
