/* goose-web — feuille unique, thème sombre, pensé mobile d'abord. */
:root {
  --fond: #0f1115;
  --fond-2: #161a21;
  --fond-3: #1e242e;
  --bord: #2a313d;
  --texte: #e6e9ef;
  --texte-doux: #9aa4b2;
  --accent: #5b9cf8;
  --accent-sombre: #2f6fd0;
  --vert: #46b97a;
  --rouge: #e05561;
  --perso: #5b9cf8;
  --pro: #b07cf5;
  --rayon: 14px;
  --saisie-h: 60px;
}

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

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--fond); color: var(--texte);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overscroll-behavior: none;
}

[hidden] { display: none !important; }

button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
button:disabled { opacity: .45; cursor: default; }

/* ---------- Connexion ---------- */
.ecran {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: radial-gradient(circle at 50% 0%, #1a2130 0%, var(--fond) 55%);
}
.carte-connexion {
  width: 100%; max-width: 420px; background: var(--fond-2);
  border: 1px solid var(--bord); border-radius: 20px; padding: 32px 26px;
  text-align: center;
}
.marque { font-size: 44px; line-height: 1; }
.carte-connexion h1 { margin: 10px 0 4px; font-size: 24px; letter-spacing: -.02em; }
.sous-titre { color: var(--texte-doux); font-size: 13.5px; margin: 0 0 26px; }
.carte-connexion input {
  width: 100%; margin-bottom: 10px; padding: 13px 14px;
  background: var(--fond-3); border: 1px solid var(--bord); border-radius: 11px;
  color: var(--texte); font-size: 16px; /* 16px = pas de zoom iOS */
}
.carte-connexion input:focus { outline: 2px solid var(--accent-sombre); border-color: transparent; }
.aide { color: var(--texte-doux); font-size: 13px; text-align: left; margin: 0 0 12px; }

.bouton-principal {
  width: 100%; padding: 14px; border-radius: 12px; margin-top: 6px;
  background: var(--accent); color: #08111f; font-weight: 650; font-size: 15px;
  transition: background .15s;
}
.bouton-principal:hover { background: #74acff; }
.message-erreur { color: var(--rouge); font-size: 13px; margin-top: 14px; }

/* ---------- Application ---------- */
.application { height: 100dvh; display: flex; flex-direction: column; }

.barre-haut {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: rgba(15, 17, 21, .85); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--bord);
  padding-top: max(8px, env(safe-area-inset-top));
  flex: 0 0 auto;
}
.bouton-icone {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  font-size: 17px; color: var(--texte-doux); flex: 0 0 auto;
}
.bouton-icone:hover { background: var(--fond-3); color: var(--texte); }

.selecteur-espace {
  flex: 1; display: flex; gap: 4px; padding: 3px;
  background: var(--fond-2); border: 1px solid var(--bord);
  border-radius: 11px; max-width: 260px; margin: 0 auto;
}
.selecteur-espace button {
  flex: 1; padding: 7px 14px; border-radius: 8px; font-size: 13.5px;
  font-weight: 600; color: var(--texte-doux); transition: all .15s;
}
.selecteur-espace button.espace-actif { color: #08111f; }
.selecteur-espace button[data-espace="perso"].espace-actif { background: var(--perso); }
.selecteur-espace button[data-espace="pro"].espace-actif { background: var(--pro); }

.zone-principale { flex: 1; display: flex; min-height: 0; position: relative; }

/* ---------- Historique ---------- */
.panneau-historique {
  width: 290px; flex: 0 0 290px; border-right: 1px solid var(--bord);
  background: var(--fond-2); display: flex; flex-direction: column; min-height: 0;
}
.entete-panneau {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 8px; font-weight: 650; font-size: 14px;
}
.bouton-petit {
  padding: 5px 10px; border-radius: 8px; background: var(--fond-3);
  font-size: 12.5px; color: var(--texte-doux); border: 1px solid var(--bord);
}
.bouton-petit:hover { color: var(--texte); }
.note-panneau { margin: 0 16px 8px; font-size: 11.5px; color: #6b7583; }

.liste-historique { overflow-y: auto; flex: 1; padding: 0 8px 16px; }
.element-histoire {
  padding: 10px 12px; border-radius: 10px; cursor: pointer; margin-bottom: 2px;
  border: 1px solid transparent;
}
.element-histoire:hover { background: var(--fond-3); }
.element-histoire.actif { background: var(--fond-3); border-color: var(--bord); }
.element-histoire .titre {
  font-size: 13.5px; font-weight: 550; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.element-histoire .meta { font-size: 11.5px; color: #6b7583; margin-top: 2px; }
.vide-historique { color: #6b7583; font-size: 13px; padding: 20px 14px; text-align: center; }

/* ---------- Conversation ---------- */
.zone-conversation { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.fil {
  flex: 1; overflow-y: auto; padding: 20px 16px calc(var(--saisie-h) + 40px);
  scroll-behavior: smooth;
}
.accueil { text-align: center; margin: 14vh auto 0; max-width: 340px; color: var(--texte-doux); }
.marque-grand { font-size: 52px; }
.accueil h2 { margin: 12px 0 6px; color: var(--texte); font-size: 20px; }
.accueil p { font-size: 13.5px; margin: 0; }

.message { max-width: 820px; margin: 0 auto 20px; }
.message.utilisateur { display: flex; justify-content: flex-end; }
.message.utilisateur .bulle {
  background: var(--accent-sombre); color: #eef4ff; padding: 11px 15px;
  border-radius: 16px 16px 4px 16px; max-width: 85%; white-space: pre-wrap;
  word-break: break-word;
}
.message.assistant .bulle { padding: 2px 0; }
.message.systeme .bulle { color: var(--texte-doux); font-size: 13px; font-family: ui-monospace, monospace; }
.message.erreur .bulle {
  background: rgba(224, 85, 97, .12); border: 1px solid rgba(224, 85, 97, .35);
  color: #ffb3ba; padding: 11px 15px; border-radius: 12px; font-size: 13.5px;
}

/* Markdown */
.bulle h1, .bulle h2, .bulle h3 { margin: 18px 0 8px; line-height: 1.3; }
.bulle h1 { font-size: 21px; } .bulle h2 { font-size: 18px; } .bulle h3 { font-size: 16px; }
.bulle p { margin: 0 0 12px; }
.bulle ul, .bulle ol { margin: 0 0 12px; padding-left: 22px; }
.bulle li { margin-bottom: 5px; }
.bulle a { color: var(--accent); }
.bulle code {
  background: var(--fond-3); padding: 2px 6px; border-radius: 5px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .89em;
}
.bulle pre {
  background: #0b0d11; border: 1px solid var(--bord); border-radius: 11px;
  padding: 0; margin: 0 0 14px; overflow: hidden;
}
.bulle pre code {
  display: block; padding: 14px 16px; overflow-x: auto; background: none;
  font-size: 13px; line-height: 1.55;
}
.bloc-code { position: relative; }
.bouton-copier {
  position: absolute; top: 8px; right: 8px; padding: 4px 9px; border-radius: 7px;
  background: rgba(255,255,255,.08); font-size: 11.5px; color: var(--texte-doux);
  opacity: 0; transition: opacity .15s;
}
.bloc-code:hover .bouton-copier, .bouton-copier:focus { opacity: 1; }
.bouton-copier:hover { background: rgba(255,255,255,.16); color: var(--texte); }
.bulle table { border-collapse: collapse; width: 100%; margin-bottom: 14px; font-size: 13.5px; }
.bulle th, .bulle td { border: 1px solid var(--bord); padding: 7px 10px; text-align: left; }
.bulle th { background: var(--fond-3); }
.bulle blockquote {
  border-left: 3px solid var(--bord); margin: 0 0 12px;
  padding: 2px 0 2px 14px; color: var(--texte-doux);
}

/* Réflexion et outils */
.reflexion { margin: 0 auto 12px; max-width: 820px; }
.reflexion-titre {
  font-size: 12.5px; color: var(--texte-doux); cursor: pointer;
  padding: 6px 0; user-select: none;
}
.reflexion-texte {
  border-left: 2px solid var(--bord); padding-left: 12px; margin-top: 4px;
  color: var(--texte-doux); font-size: 13px; white-space: pre-wrap; max-height: 240px;
  overflow-y: auto;
}
.outils { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 auto 12px; max-width: 820px; }
.outil {
  font-size: 12px; padding: 3px 10px; border-radius: 20px;
  background: var(--fond-3); border: 1px solid var(--bord); color: var(--texte-doux);
  display: inline-flex; align-items: center; gap: 6px;
}
.outil.en-cours::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); animation: pulsation 1.1s infinite;
}
.outil.termine { opacity: .62; }
.outil.termine::before { content: "✓"; color: var(--vert); font-size: 10px; }
@keyframes pulsation { 0%,100% { opacity: .25; } 50% { opacity: 1; } }

.curseur { display: inline-block; width: 7px; height: 16px; background: var(--accent);
  vertical-align: text-bottom; animation: clignote 1s steps(2) infinite; }
@keyframes clignote { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* ---------- Saisie ---------- */
.zone-saisie {
  position: sticky; bottom: 0; padding: 10px 16px max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--fond) 62%, transparent);
  flex: 0 0 auto;
}
.fichiers-joints { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; max-width: 820px; margin-inline: auto; }
.joint {
  font-size: 12.5px; background: var(--fond-3); border: 1px solid var(--bord);
  border-radius: 8px; padding: 4px 8px; display: flex; align-items: center; gap: 6px;
}
.joint button { color: var(--texte-doux); font-size: 14px; line-height: 1; }

.ligne-saisie {
  display: flex; align-items: flex-end; gap: 6px; max-width: 820px; margin: 0 auto;
  background: var(--fond-2); border: 1px solid var(--bord); border-radius: 18px;
  padding: 6px; transition: border-color .15s;
}
.ligne-saisie:focus-within { border-color: var(--accent-sombre); }
.ligne-saisie textarea {
  flex: 1; resize: none; border: 0; background: none; color: var(--texte);
  font: inherit; font-size: 16px; padding: 9px 4px; max-height: 42dvh; outline: none;
  line-height: 1.45;
}
.bouton-envoyer {
  width: 38px; height: 38px; border-radius: 50%; background: var(--accent);
  color: #08111f; font-size: 17px; font-weight: 700; flex: 0 0 auto;
  display: grid; place-items: center;
}
.bouton-envoyer:disabled { background: var(--fond-3); color: #4d5663; }
.bouton-envoyer.arreter { background: var(--rouge); color: #fff; font-size: 13px; }

.indicateur { max-width: 820px; margin: 6px auto 0; font-size: 12px; color: #6b7583; }
.indicateur.occupe::after {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); margin-left: 7px; animation: pulsation 1.1s infinite;
}

/* ---------- Réglages ---------- */
.voile { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; }
.panneau-lateral {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 92vw);
  background: var(--fond-2); border-left: 1px solid var(--bord); z-index: 50;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.contenu-reglages { padding: 8px 18px 30px; overflow-y: auto; }
.contenu-reglages h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: #6b7583; margin: 22px 0 10px;
}
.ligne-passkey, .ligne-fichier {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--bord); font-size: 13.5px;
}
.ligne-passkey .nom, .ligne-fichier .nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-passkey .date, .ligne-fichier .taille { color: #6b7583; font-size: 11.5px; flex: 0 0 auto; }
.ligne-fichier a { color: var(--accent); text-decoration: none; font-size: 12.5px; }
.bouton-secondaire {
  width: 100%; margin-top: 10px; padding: 11px; border-radius: 10px;
  background: var(--fond-3); border: 1px solid var(--bord); font-size: 13.5px;
}
.bouton-secondaire:hover { background: #262d38; }
.bouton-secondaire.danger { color: var(--rouge); border-color: rgba(224,85,97,.3); }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .panneau-historique {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 45;
    transform: translateX(-100%); transition: transform .22s ease;
    padding-top: env(safe-area-inset-top);
  }
  .panneau-historique.ouvert { transform: translateX(0); }
  .fil { padding: 14px 12px calc(var(--saisie-h) + 34px); }
  .message.utilisateur .bulle { max-width: 88%; }
  .zone-saisie { padding-inline: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .fil { scroll-behavior: auto; }
}
