*{box-sizing:border-box}
html,body{margin:0;height:100%;font-family:system-ui,-apple-system,Arial,sans-serif}
body{background:#edf1f7;color:#16233b}
[hidden]{display:none!important}
.studio-v2{
 display:flex;flex-direction:column;
 width:100%;max-width:900px;
 height:100vh;height:100dvh;
 margin:auto;background:#fff;
 overflow:hidden
}
.v2-header{
 display:flex;align-items:center;gap:11px;
 padding:12px 15px;
 border-bottom:1px solid #e5eaf1;
 flex-shrink:0;background:white
}
.v2-back{font-size:25px;text-decoration:none;color:#243750}
.v2-logo{
 width:42px;height:42px;display:grid;place-items:center;
 border-radius:13px;background:#e9efff;color:#2958c8;
 font-size:25px
}
.v2-identity{flex:1;min-width:0;display:flex;flex-direction:column}
.v2-identity strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.v2-identity small{color:#66758b}
.v2-new{border:1px solid #dbe3ef;background:white;border-radius:12px;padding:10px;color:#234ba7}
.v2-messages{
 flex:1;min-height:0;overflow-y:auto;
 padding:20px 16px;
 overscroll-behavior:contain;
 scroll-behavior:auto
}
.v2-welcome{text-align:center;max-width:480px;margin:48px auto;color:#55657e}
.v2-welcome h2{color:#182a47}
.v2-welcome-icon{font-size:42px;color:#4169d3}
.v2-message{display:flex;margin:12px 0}
.v2-message.user{justify-content:flex-end}
.v2-message.assistant{justify-content:flex-start}
.v2-bubble{
 max-width:88%;padding:12px 15px;
 border-radius:17px;line-height:1.55;
 white-space:pre-wrap;overflow-wrap:anywhere;
 font-size:15px
}
.user .v2-bubble{background:#2459cc;color:white;border-bottom-right-radius:5px}
.assistant .v2-bubble{background:#f0f3f8;color:#1e293b;border-bottom-left-radius:5px}
.v2-footer{
 padding:10px 13px calc(10px + env(safe-area-inset-bottom));
 border-top:1px solid #e7ebf1;background:white;
 flex-shrink:0
}
.v2-composer{
 display:flex;align-items:flex-end;gap:8px;
 border:1px solid #d9e1ec;border-radius:20px;
 padding:7px;background:#f8fafc
}
.v2-composer textarea{
 flex:1;min-width:0;min-height:38px;max-height:130px;
 resize:none;outline:none;border:none;background:transparent;
 padding:9px;font:inherit;line-height:21px
}
.v2-composer button{
 flex-shrink:0;width:42px;height:42px;
 border:0;border-radius:14px;background:#2459cc;
 color:white;font-size:20px
}
.v2-composer button:disabled{opacity:.5}
.v2-footer>small{
 display:block;text-align:center;margin-top:7px;
 font-size:11px;color:#8a94a6
}
.v2-error{padding:9px 15px;background:#fff0f0;color:#a32626}
@media(min-width:901px){
 .studio-v2{box-shadow:0 0 30px #d8deea}
}
@media(max-width:480px){
 .v2-messages{padding:12px}
 .v2-bubble{max-width:94%}
 .v2-new{font-size:12px;padding:8px}
}

/* Actions de chaque réponse IA */
.v2-message.assistant {
  flex-direction: column;
  align-items: flex-start;
}
.v2-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 0 6px;
}
.v2-actions button {
  border: 1px solid #e0e6ef;
  background: #fff;
  color: #52617a;
  border-radius: 11px;
  padding: 7px 11px;
  font-size: 12px;
  cursor: pointer;
}
.v2-actions button:active {
  background: #eef2f8;
}

#v2MicButton, #v2ImageButton {
  flex-shrink:0;
  width:38px;
  height:42px;
  border:0;
  background:transparent;
  color:#2459cc;
  font-size:23px;
  border-radius:12px;
}
#v2MicButton:disabled{opacity:.4}

/* Chat V2 - aperçu image */
.v2-image-preview {
  position:relative;
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px;
  margin-bottom:8px;
  background:#f2f5fb;
  border-radius:12px;
}
.v2-image-preview[hidden]{display:none}
.v2-image-preview img{
  max-width:100px;
  max-height:85px;
  object-fit:contain;
  border-radius:9px;
}
.v2-image-preview button{
  width:32px;
  height:32px;
  border:0;
  border-radius:9px;
  background:#fff;
  color:#b42318;
  cursor:pointer;
}


/* V2_MIC_TEMP_HIDDEN */
#v2MicButton {
    display: none !important;
}


/* ARLINUS_V2_HIDE_AUDIO_ALL */

/* Microphone */
#v2MicButton {
    display: none !important;
}

/* Lecture audio sous les réponses */
.v2-actions button[title="Écouter"],
.v2-actions button[title="Arrêter"],
.v2-actions button[aria-label="Écouter"],
.v2-actions button[aria-label="Arrêter"] {
    display: none !important;
}

/* ARLINUS_V2_IMAGE_PRO_01 */

.v2-image-preview:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin: 8px 12px;
  background: #f2f6ff;
  border: 1px solid #dfe8fa;
  border-radius: 18px;
  box-shadow: 0 2px 8px rgba(20,45,95,.05);
}

.v2-image-preview .v2-preview-picture {
  width: 82px;
  height: 82px;
  max-width: 82px;
  max-height: 82px;
  object-fit: cover;
  border-radius: 13px;
  cursor: zoom-in;
  flex-shrink: 0;
}

.v2-preview-filename {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: #354361;
}

.v2-image-preview button {
  flex-shrink: 0;
}

.v2-sent-image-wrap {
  margin-top: 10px;
}

.v2-sent-image {
  display: block;
  width: auto;
  max-width: min(230px, 100%);
  max-height: 280px;
  object-fit: contain;
  border-radius: 14px;
  cursor: zoom-in;
  background: #eaf0fa;
}

.v2-image-viewer {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(8,15,32,.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.v2-image-viewer img {
  display: block;
  max-width: 96vw;
  max-height: 86dvh;
  object-fit: contain;
  border-radius: 10px;
}

.v2-image-viewer-close {
  position: absolute;
  top: 22px;
  right: 18px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #172033;
  font-size: 24px;
  cursor: pointer;
}


/* ARLINUS_V2_IMAGE_DISPLAY_FIX_02 */
.v2-sent-image-wrap {
  display: block;
  margin-top: 10px;
  width: 100%;
}

.v2-sent-image {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
  max-height: 360px;
  object-fit: contain;
  border-radius: 14px;
  background: rgba(255,255,255,.95);
  cursor: zoom-in;
}

.v2-image-preview img {
  object-fit: cover;
}



/* ARLINUS_V2_LAST_EDIT_01 */

.v2-edit-menu {
  position: fixed;
  bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  gap: 8px;
  padding: 9px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 35px rgba(0,0,0,.18);
  border: 1px solid #e5e7eb;
  max-width: calc(100vw - 24px);
}

.v2-edit-menu button {
  border: none;
  background: #f1f5f9;
  padding: 11px 13px;
  border-radius: 11px;
  color: #1e293b;
  font-size: 14px;
  white-space: nowrap;
}

.v2-edit-menu button:disabled {
  opacity: .5;
}

.v2-edit-notice:not([hidden]) {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.v2-edit-notice button {
  border: none;
  background: transparent;
  color: #b91c1c;
  font-weight: 600;
}

.v2-message.user .v2-bubble {
  -webkit-touch-callout: none;
}



/* ARLINUS_V2_SAFE_MARKDOWN_01 */
.v2-message.assistant .v2-bubble {
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.v2-message.assistant .v2-bubble p {
  margin: 0 0 10px;
}
.v2-message.assistant .v2-bubble p:last-child {
  margin-bottom: 0;
}
.v2-message.assistant .v2-bubble h1,
.v2-message.assistant .v2-bubble h2,
.v2-message.assistant .v2-bubble h3,
.v2-message.assistant .v2-bubble h4 {
  font-size: 1.04em;
  font-weight: 750;
  line-height: 1.4;
  margin: 14px 0 7px;
}
.v2-message.assistant .v2-bubble ul,
.v2-message.assistant .v2-bubble ol {
  padding-left: 22px;
  margin: 8px 0 12px;
}
.v2-message.assistant .v2-bubble li {
  margin: 4px 0;
}
.v2-message.assistant .v2-bubble pre {
  overflow-x: auto;
  padding: 12px;
  border-radius: 11px;
  background: #172033;
  color: #f8fafc;
  font-size: 12px;
}
.v2-message.assistant .v2-bubble code {
  overflow-wrap: anywhere;
  font-size: .9em;
}


/* ARLINUS_V2_IMAGE_240PX_FINAL */
/* Miniature envoyée dans la conversation */
.v2-sent-image-wrap {
    display: block;
    max-width: 100%;
    margin-top: 8px;
}

.v2-sent-image-wrap img.v2-sent-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 240px;
    object-fit: contain;
    border-radius: 12px;
    cursor: zoom-in;
}


/* ARLINUS_V2_IMAGE_BUBBLE_CLEAN_04 */
.v2-message.user .v2-bubble.v2-image-bubble {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    color: inherit !important;
}

.v2-message.user .v2-image-bubble img.v2-sent-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 240px;
    object-fit: contain;
    border-radius: 12px;
    cursor: zoom-in;
}

.v2-image-unavailable {
    color: #64748b;
    font-size: 13px;
}


/* ARLINUS_V2_MATH_TABLES_01 */

/* Tableau horizontal sur telephone */
.v2-message.assistant .v2-table-scroll {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    margin: 12px 0;
    border: 1px solid #d7e0ed;
    border-radius: 12px;
    background: #fff;
}

.v2-message.assistant .v2-data-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    white-space: normal;
    font-size: 14px;
    line-height: 1.5;
}

.v2-message.assistant .v2-data-table th,
.v2-message.assistant .v2-data-table td {
    padding: 11px 12px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    overflow-wrap: normal;
    word-break: normal;
    min-width: 95px;
    max-width: 290px;
}

.v2-message.assistant .v2-data-table th {
    font-weight: 700;
    color: #1e3a5f;
    background: #eaf1fc;
}

.v2-message.assistant .v2-data-table tr:last-child td {
    border-bottom: none;
}

.v2-message.assistant .v2-data-table td:last-child,
.v2-message.assistant .v2-data-table th:last-child {
    border-right: none;
}

/* Fractions et equations */
.v2-message.assistant mjx-container {
    max-width: 100%;
    color: #1e293b;
}

.v2-message.assistant mjx-container[display="true"] {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 2px;
    margin: 12px 0;
}


/* ARLINUS_V2_COMPOSER_ALIGN_01 */
/* Alignement vertical du champ de saisie mobile */

textarea[id="messageInput"] {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 24px;
    max-height: 130px;
    height: auto;
    margin: 0;
    padding: 2px 0;
    line-height: 1.45;
    vertical-align: middle;
    align-self: center;
    resize: none;
    box-sizing: border-box;
}

textarea[id="messageInput"]::placeholder {
    line-height: 1.45;
}

/* ARLINUS_SUPPORT_SYNC_HUMAIN_V3 — message humain distinct de l'IA */
.v2-message.creator { flex-direction:column; align-items:flex-start; }
.v2-message.creator .v2-bubble {
  background:#e9f8ee; color:#174b33; border:1px solid #c6ead4;
  border-bottom-left-radius:5px; max-width:94%;
}
.v2-human-author {
  display:inline-flex; align-items:center; gap:5px; margin:0 0 5px 8px;
  font-size:12px; font-weight:700; color:#207048;
}


/* ARLINUS_V2_HUMAN_BUBBLE_V5
   Repère humain au-dessus, texte dans une vraie bulle.
   Ne modifie aucun message IA ou utilisateur. */
.v2-messages .v2-message.creator {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  gap: 5px !important;
  width: 100%;
  margin: 14px 0 !important;
}
.v2-messages .v2-message.creator .v2-human-author {
  display: inline-flex !important;
  align-items: center;
  width: auto !important;
  max-width: 94%;
  margin: 0 0 2px 7px !important;
  padding: 0;
  color: #21654b;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.4;
  white-space: nowrap;
}
.v2-messages .v2-message.creator .v2-bubble {
  display: block !important;
  flex: 0 1 auto !important;
  width: fit-content !important;
  min-width: 0;
  max-width: min(86%, 620px) !important;
  margin: 0 !important;
  padding: 12px 15px !important;
  border: 1px solid #cce9d8 !important;
  border-radius: 16px 16px 16px 5px !important;
  background: #e9f8ef !important;
  color: #173c2b !important;
  box-shadow: 0 1px 3px rgba(15, 65, 37, .06);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
  font-size: 15px;
}
@media (max-width:480px) {
  .v2-messages .v2-message.creator .v2-bubble {
    max-width: 93% !important;
  }
}


/* ARLINUS_CHATV2_TYPO_PRO_V1 */
/* Présentation seulement : aucune logique métier ou messagerie modifiée. */
.v2-messages { padding: 18px 16px 22px; }
.v2-message { margin: 11px 0; }
.v2-message .v2-bubble {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.52;
  letter-spacing: 0;
  padding: 11px 14px;
  max-width: min(87%, 680px);
  border-radius: 16px;
  overflow-wrap: break-word;
}
.v2-message.assistant .v2-bubble {
  line-height: 1.55;
  color: #253449;
  background: #f2f5f9;
  border-bottom-left-radius: 5px;
}
.v2-message.user .v2-bubble:not(.v2-image-bubble) {
  line-height: 1.48;
  border-bottom-right-radius: 5px;
}
.v2-message.assistant .v2-bubble p { margin: 0 0 8px; }
.v2-message.assistant .v2-bubble p:last-child { margin-bottom: 0; }
.v2-message.assistant .v2-bubble h1,
.v2-message.assistant .v2-bubble h2,
.v2-message.assistant .v2-bubble h3,
.v2-message.assistant .v2-bubble h4 { line-height: 1.35; margin: 10px 0 5px; font-weight: 700; }
.v2-message.assistant .v2-bubble li { margin: 3px 0; }
.v2-welcome { max-width: 430px; margin: 40px auto; line-height: 1.5; }
.v2-welcome h2 { font-weight: 700; letter-spacing: -.02em; }
.v2-welcome p { font-size: 15px; line-height: 1.55; }
.v2-messages .v2-message.creator .v2-bubble {
  font-size: 15px !important; line-height: 1.52 !important;
  max-width: min(87%, 680px) !important;
}
.v2-composer textarea { font-size: 15px; line-height: 1.4; }
@media (max-width: 480px) {
  .v2-messages { padding: 14px 12px 20px; }
  .v2-message .v2-bubble { max-width: 91%; font-size: 14.5px; padding: 11px 13px; }
  .v2-message.assistant .v2-bubble { line-height: 1.53; }
  .v2-messages .v2-message.creator .v2-bubble { max-width: 91% !important; font-size: 14.5px !important; }
  .v2-welcome { margin: 32px auto; }
  .v2-welcome p { font-size: 14.5px; }
}


/* ARLINUS_CHATV2_TEXTE_NET_V1 */
/* Texte plus soutenu et lisible, sans transformer la mise en page. */
.v2-message.assistant .v2-bubble {
  color: #17212f !important;
  font-weight: 450;
  -webkit-font-smoothing: auto;
  text-rendering: optimizeLegibility;
}
.v2-message.assistant .v2-bubble p,
.v2-message.assistant .v2-bubble li {
  color: #17212f;
  font-weight: 450;
}
.v2-message.assistant .v2-bubble strong,
.v2-message.assistant .v2-bubble b { font-weight: 700; }
.v2-message.user .v2-bubble { font-weight: 500; }
.v2-messages .v2-message.creator .v2-bubble { font-weight: 500; }
.v2-message.assistant .v2-bubble h1,
.v2-message.assistant .v2-bubble h2,
.v2-message.assistant .v2-bubble h3,
.v2-message.assistant .v2-bubble h4 { color: #101827; font-weight: 700; }

/* ARLINUS_CHATV2_TEXTE_EQUILIBRE_V2 */
/* Lecture confortable : texte courant régulier et net, emphase distincte. */
.v2-messages .v2-message.assistant .v2-bubble {
  color: #243042 !important;
  font-weight: 400 !important;
  line-height: 1.52 !important;
  letter-spacing: 0 !important;
}
.v2-messages .v2-message.assistant .v2-bubble p,
.v2-messages .v2-message.assistant .v2-bubble li,
.v2-messages .v2-message.assistant .v2-bubble ul,
.v2-messages .v2-message.assistant .v2-bubble ol {
  color: inherit !important;
  font-weight: 400 !important;
  line-height: 1.52 !important;
}
.v2-messages .v2-message.assistant .v2-bubble strong,
.v2-messages .v2-message.assistant .v2-bubble b,
.v2-messages .v2-message.assistant .v2-bubble p strong,
.v2-messages .v2-message.assistant .v2-bubble li strong {
  font-weight: 650 !important;
}
.v2-messages .v2-message.assistant .v2-bubble h1,
.v2-messages .v2-message.assistant .v2-bubble h2,
.v2-messages .v2-message.assistant .v2-bubble h3,
.v2-messages .v2-message.assistant .v2-bubble h4 {
  color: #172033 !important;
  font-weight: 650 !important;
}
.v2-messages .v2-message.assistant .v2-bubble li { margin-top: 3px !important; margin-bottom: 3px !important; }
.v2-messages .v2-message.user .v2-bubble { color: #fff !important; font-weight: 450 !important; }
.v2-messages .v2-message.creator .v2-bubble { font-weight: 400 !important; }
@media (max-width: 480px) {
 .v2-messages .v2-message.assistant .v2-bubble { font-size: 15px !important; }
}


/* ARLINUS_TYPING_INDICATOR_V1 : indicateur non intrusif Chat V2 */
.v2-bubble.v2-typing-indicator { display: inline-flex; align-items: center; gap: 9px; min-height: 38px; padding: 10px 14px; }
.v2-typing-label { font-size: 13px; color: #475569; font-weight: 500; }
.v2-typing-dots { display: inline-flex; gap: 4px; align-items: center; }
.v2-typing-dots span { width: 5px; height: 5px; border-radius: 50%; background: #64748b; animation: v2TypingPulse 1.25s infinite ease-in-out; }
.v2-typing-dots span:nth-child(2) { animation-delay: .16s; }
.v2-typing-dots span:nth-child(3) { animation-delay: .32s; }
@keyframes v2TypingPulse { 0%, 65%, 100% { opacity: .3; transform: translateY(0); } 32% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .v2-typing-dots span { animation: none; opacity: .8; } }
