:root {
  --fond: #f5f1ea;
  --fond-barre: #efe9df;
  --carte: #ffffff;
  --saisie: #ffffff;
  --bulle: #e9e3d7;
  --texte: #2b2a27;
  --doux: #77736a;
  --ligne: #e0d9cc;
  --accent: #c96442;
  --accent-fonce: #ad5234;
  --survol: rgba(0,0,0,.045);
  --ombre: 0 4px 20px rgba(60,40,20,.08);
  --ok: #3f8f5a;
  --erreur: #b3402e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #262624; --fond-barre: #1f1e1c; --carte: #30302e; --saisie: #30302e; --bulle: #141413;
    --texte: #ece9e1; --doux: #a19d93; --ligne: #3d3c39; --survol: rgba(255,255,255,.05);
    --ombre: 0 4px 24px rgba(0,0,0,.35); --accent: #d97757; --accent-fonce: #c96442;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--fond); color: var(--texte); font: 15px/1.6 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.serif, h1, .marque { font-family: "Source Serif 4", Georgia, serif; font-weight: 400; }

.etoile { color: var(--accent); display: inline-block; }
.etoile.grande { font-size: 1.1em; }
.marque { display: flex; align-items: center; gap: 8px; font-size: 21px; letter-spacing: -.01em; }

/* Connexion */
.connexion { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.connexion-carte { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.connexion-carte .marque { justify-content: center; font-size: 26px; margin-bottom: 12px; }
.connexion-carte h1 { font-size: 34px; letter-spacing: -.02em; }
.connexion-carte p { color: var(--doux); }
.connexion-carte input { padding: 13px 15px; border-radius: 12px; border: 1px solid var(--ligne); background: var(--saisie); outline: none; }
.connexion-carte input:focus { border-color: var(--accent); }
.btn-principal { padding: 12px; border-radius: 12px; background: var(--texte); color: var(--fond); font-weight: 500; }
.btn-principal:hover { opacity: .9; }
.erreur { color: var(--erreur) !important; min-height: 1.5em; font-size: 14px; }

/* Structure */
.app { display: flex; height: 100%; height: 100dvh; }
.barre { width: 280px; flex: none; background: var(--fond-barre); border-right: 1px solid var(--ligne); display: flex; flex-direction: column; padding: 12px; transition: margin .25s; }
.app.repliee .barre { margin-left: -280px; }
.barre-haut { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 14px; }
.icone { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: var(--doux); }
.icone:hover { background: var(--survol); color: var(--texte); }
.nouvelle { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; font-weight: 500; color: var(--accent); }
.nouvelle span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 17px; line-height: 1; }
.nouvelle:hover { background: var(--survol); }
.section-titre { font-size: 12px; color: var(--doux); padding: 18px 10px 6px; font-weight: 500; }
.liste { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.liste a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; font-size: 14px; white-space: nowrap; overflow: hidden; }
.liste a span { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.liste a:hover { background: var(--survol); }
.liste a.actif { background: var(--bulle); }
.liste a i { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.3s infinite; }
.liste .vide { color: var(--doux); font-size: 13px; padding: 8px 10px; }
.barre-bas { border-top: 1px solid var(--ligne); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.agent { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--doux); padding: 0 10px; }
.agent i { width: 7px; height: 7px; border-radius: 50%; background: var(--doux); }
.agent.en-ligne i { background: var(--ok); box-shadow: 0 0 0 3px rgba(63,143,90,.18); }
.profil { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--texte); color: var(--fond); font-size: 13px; font-weight: 600; text-transform: uppercase; }
.profil .nom { flex: 1; font-size: 14px; font-weight: 500; }

.principal { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.entete { display: flex; align-items: center; gap: 10px; padding: 10px 14px; min-height: 54px; }
#ouvrir { display: none; }
.app.repliee #ouvrir { display: grid; }
.titre-conv { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.statut-conv { margin-left: auto; font-size: 12px; color: var(--doux); padding: 3px 10px; border: 1px solid var(--ligne); border-radius: 999px; white-space: nowrap; }
.statut-conv:empty { display: none; }
.voile { display: none; }

/* Accueil */
.accueil { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 0 16px 12vh; }
.salut { font-size: clamp(30px, 5vw, 42px); letter-spacing: -.02em; margin-bottom: 30px; text-align: center; }
#emplacement-accueil { width: 100%; max-width: 680px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; max-width: 680px; }
.suggestions button { padding: 7px 13px; border: 1px solid var(--ligne); border-radius: 10px; font-size: 13.5px; color: var(--doux); background: transparent; }
.suggestions button:hover { background: var(--survol); color: var(--texte); }

/* Saisie */
.saisie { background: var(--saisie); border: 1px solid var(--ligne); border-radius: 20px; padding: 14px 14px 10px 16px; box-shadow: var(--ombre); transition: border-color .2s; }
.saisie:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--ligne)); }
.saisie textarea { width: 100%; border: none; outline: none; resize: none; background: transparent; font-size: 16px; line-height: 1.5; max-height: 220px; min-height: 26px; }
.saisie textarea::placeholder { color: var(--doux); }
.saisie-bas { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.options { display: flex; gap: 6px; flex-wrap: wrap; }
.pastille { padding: 5px 11px; border: 1px solid var(--ligne); border-radius: 9px; font-size: 13px; color: var(--doux); white-space: nowrap; }
.pastille:hover { background: var(--survol); color: var(--texte); }
.menu-wrap { position: relative; }
.menu { position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 20; min-width: 200px; background: var(--carte); border: 1px solid var(--ligne); border-radius: 12px; box-shadow: var(--ombre); padding: 6px; display: flex; flex-direction: column; }
.pied .menu { bottom: calc(100% + 6px); }
.accueil .menu { bottom: auto; top: calc(100% + 6px); }
.menu button, .menu label { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; font-size: 14px; text-align: left; cursor: pointer; }
.menu button:hover, .menu label:hover { background: var(--survol); }
.menu input { accent-color: var(--accent); }
.menu .pt { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.aide-action { margin-left: auto; font-size: 12.5px; color: var(--doux); text-align: right; }
.envoyer { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; transition: opacity .2s; }
.envoyer svg { stroke-width: 2.2; width: 18px; height: 18px; }
.envoyer:disabled { opacity: .35; cursor: default; }
.envoyer:not(:disabled):hover { background: var(--accent-fonce); }

/* Conversation */
.conversation { flex: 1; overflow-y: auto; padding: 10px 16px 30px; }
.fil { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 26px; }
.msg-user { align-self: flex-end; max-width: 85%; background: var(--bulle); padding: 10px 16px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; }
.msg-user small { display: block; color: var(--doux); font-size: 12px; margin-top: 4px; }
.msg-ia { display: flex; gap: 14px; align-items: flex-start; }
.msg-ia > .etoile { font-size: 22px; line-height: 1.2; flex: none; margin-top: 1px; }
.msg-ia.travail > .etoile { animation: tourne 2.4s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
.corps { flex: 1; min-width: 0; font-family: "Source Serif 4", Georgia, serif; font-size: 16.5px; line-height: 1.65; }
.corps p + p, .corps p + .carte, .corps .carte + p, .corps .carte + .carte, .corps p + .boutons, .corps .carte + .boutons { margin-top: 12px; }
.corps .doux { color: var(--doux); }
.corps h3 { font-size: 20px; font-weight: 500; margin-bottom: 4px; }
.corps .ui { font-family: Inter, system-ui, sans-serif; font-size: 14px; }
.travail-ligne { display: flex; align-items: center; gap: 10px; color: var(--doux); font-family: Inter, sans-serif; font-size: 14px; }
.barre-prog { height: 4px; border-radius: 4px; background: var(--ligne); overflow: hidden; margin-top: 8px; max-width: 320px; }
.barre-prog i { display: block; height: 100%; background: var(--accent); transition: width .4s; }
.barre-prog.indet i { width: 35% !important; animation: indet 1.4s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: 14px; overflow: hidden; font-family: Inter, sans-serif; font-size: 14px; }
.carte-tete { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--ligne); font-weight: 500; }
.carte-tete .doux { margin-left: auto; font-weight: 400; font-size: 12.5px; }
.plan { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--ligne); }
.plan:last-child { border-bottom: none; }
.plan .n { font-size: 12px; color: var(--doux); padding-top: 2px; }
.plan .qui { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; }
.plan .qui i { width: 9px; height: 9px; border-radius: 50%; }
.plan .meta { font-weight: 400; color: var(--doux); font-size: 12px; }
.plan .replique { width: 100%; border: 1px solid transparent; border-radius: 8px; background: transparent; resize: none; padding: 4px 6px; margin: 2px -6px 0; font-size: 14.5px; line-height: 1.5; outline: none; overflow: hidden; }
.plan .replique:hover:not([readonly]) { border-color: var(--ligne); }
.plan .replique:focus { border-color: var(--accent); background: var(--fond); }
.plan .action { color: var(--doux); font-size: 13px; font-style: italic; }
.chute { padding: 12px 16px; background: color-mix(in srgb, var(--accent) 8%, transparent); font-size: 13.5px; }

.boutons { display: flex; flex-wrap: wrap; gap: 8px; font-family: Inter, sans-serif; }
.btn { padding: 8px 15px; border-radius: 10px; border: 1px solid var(--ligne); font-size: 14px; font-weight: 500; background: var(--carte); }
.btn:hover { background: var(--survol); }
.btn.plein { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.plein:hover { background: var(--accent-fonce); }
.btn:disabled { opacity: .5; cursor: default; }

.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 12px; }
.mini { position: relative; border-radius: 10px; overflow: hidden; border: 2px solid transparent; cursor: pointer; background: var(--fond); text-align: left; padding: 0; }
.mini img { display: block; width: 100%; aspect-ratio: 9/16; object-fit: cover; }
.mini span { display: block; padding: 6px 8px; font-size: 12px; line-height: 1.35; }
.mini.choisie { border-color: var(--accent); }
.mini.choisie::after { content: "✓"; position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; }
.media { padding: 12px; display: grid; gap: 10px; }
.media video { width: 100%; max-height: 70vh; border-radius: 10px; background: #000; }
.media audio { width: 100%; }
.media .fichier { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.media a { color: var(--accent); }
.echec { border-color: color-mix(in srgb, var(--erreur) 40%, var(--ligne)); }
.echec .carte-tete { color: var(--erreur); }
.echec pre { padding: 10px 16px; font-size: 12.5px; white-space: pre-wrap; color: var(--doux); }

.pied { padding: 0 16px 10px; }
#emplacement-pied { max-width: 720px; margin: 0 auto; }
.mention { text-align: center; font-size: 11.5px; color: var(--doux); margin-top: 8px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); padding: 10px 18px; border-radius: 10px; background: var(--texte); color: var(--fond); font-size: 14px; z-index: 50; box-shadow: var(--ombre); max-width: calc(100% - 32px); }
.toast.mauvais { background: var(--erreur); color: #fff; }

@media (max-width: 800px) {
  .barre { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; margin-left: -290px; box-shadow: var(--ombre); }
  .app.ouverte .barre { margin-left: 0; }
  .app.ouverte .voile { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.3); }
  #ouvrir { display: grid !important; }
  .aide-action { display: none; }
  .accueil { justify-content: flex-start; padding-top: 14vh; }
}
