/* UI overlay — lightweight, non-breaking */

:root{
  --paper-bg: #ece7dd;
  --paper: #fffdf8;
  --ink: #1c1c1c;
  --line: rgba(0,0,0,0.05);
  --shadow: rgba(0,0,0,0.12);
  --postit: #fff59d;
}

/* Page background */
body{
  background: var(--paper-bg);
  color: var(--ink);
}

/* A4-like wrapper (only if these elements exist) */
#header, #chat, #inputZone{
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

#chat{
  background: var(--paper);
  border-radius: 8px;
  box-shadow: 0 10px 30px var(--shadow);
  padding: 18px 16px;
  position: relative;
  overflow: auto;
}

/* subtle ruled lines overlay */
#chat::before{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 26px,
    var(--line) 27px
  );
  border-radius: 8px;
}

/* Ensure messages sit above lines */
#chat > *{ position: relative; }

/* Post-it */
#memory-postit{
  position: fixed;
  top: 12px;
  right: 12px;
  width: 190px;
  background: var(--postit);
  padding: 12px 12px 14px;
  border-radius: 3px;
  box-shadow: 0 10px 22px rgba(0,0,0,0.18);
  transform: rotate(1.2deg);
  z-index: 9999;
  font-size: 13px;
  line-height: 1.35;
}

#memory-postit h4{
  margin: 0 0 6px 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .5px;
}

#memory-postit ul{
  margin: 0;
  padding-left: 16px;
}

#memory-postit .muted{
  opacity: .75;
  font-size: 12px;
}

/* Mobile-first: compact + doesn't hide input */
@media (max-width: 700px){
  #memory-postit{
    top: auto;
    bottom: 64px; /* stays above input zone */
    right: 10px;
    width: 160px;
    font-size: 12px;
  }
}

/* POSTIT_COLLAPSE_STEP2_1 */
#memory-postit .postit-body { display: block; }
#memory-postit.is-collapsed .postit-body { display: none; }
#memory-postit .postit-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
#memory-postit .postit-toggle {
  font-size: 12px;
  opacity: .8;
}

/* MOBILE_VIEW_02_10 — téléphone : pleine largeur, texte lisible sans zoom, saisie au pouce */
@media (max-width: 700px){
  html, body{ overflow-x: clip; } /* « hidden » casserait la barre du compte collée en haut */
  body{ font-size: 16px; }
  #header{ padding: 0 12px; }
  #header h1{ font-size: 20px; margin: 8px 0 2px; }
  #header h2{ font-size: 13px; margin: 0 0 6px; }
  #chat{
    border-radius: 0;
    box-shadow: none;
    padding: 10px 8px 12px !important;
    min-height: calc(100vh - 140px);
  }
  #chat p.msg{ max-width: 96% !important; font-size: 16px; line-height: 1.5; }
  #chat p.msg .author{ font-size: 12px; }
  body{ padding-bottom: 68px; }
  #inputZone{
    position: fixed;
    left: 0; right: 0;
    bottom: 0;
    max-width: none;
    z-index: 60;
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 8px;
    background: var(--paper-bg);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    box-sizing: border-box;
    width: 100%;
  }
  #inputZone #userInput{
    flex: 1 1 auto;
    min-width: 0;
    font-size: 16px; /* sous 16px, le téléphone zoome tout seul à la saisie */
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 12px;
  }
  #inputZone button{ min-height: 44px; padding: 8px 12px; font-size: 15px; flex: 0 0 auto; }
  #captureBtn{ padding: 8px 10px; }
  /* barre du compte : toujours visible en haut, opaque, sur une seule ligne */
  #alfred-account-switcher{
    font-size: 14px !important; padding: 6px 8px !important;
    position: sticky !important; top: 0; z-index: 70;
    background: var(--paper-bg) !important; backdrop-filter: none !important; opacity: 1 !important;
    flex-wrap: nowrap !important; box-shadow: 0 2px 6px rgba(0,0,0,0.10) !important;
  }
  #alfred-account-switcher > div:first-child{ display: none; } /* « Compte : » : la liste parle d'elle-même, place gagnée pour le sélecteur de langue */
  #alfred-active-account-badge{ display: none; } /* redit le compte déjà affiché dans la liste */
  #alfred-account-select{ flex: 1 1 auto; min-width: 0; }
  #alfred-account-rename{ flex: 0 0 auto; }
  #alfred-account-select{ max-width: 55vw; font-size: 15px; }
  /* le post-it mémoire reçoit des styles en ligne (memory-ui.js) : sur téléphone il devient
     un bandeau en haut de page, qui défile avec elle et ne cache plus les réponses */
  #memory-postit{
    position: static !important;
    max-width: none !important;
    width: auto;
    margin: 6px 8px !important;
    padding: 6px 10px !important;
    font-size: 12px !important;
    box-shadow: none !important;
    transform: none;
  }
}

/* CAPTURES_DANS_LA_CONVERSATION_02_10 — miniatures cliquables + visionneuse plein écran */
#chat p.msg .msg-thumbs{ display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#chat p.msg .msg-thumb{
  padding: 0; border: 1px solid rgba(0,0,0,0.15); border-radius: 8px; overflow: hidden;
  width: 72px; height: 128px; background: #ddd; cursor: zoom-in;
}
#chat p.msg .msg-thumb img{ width: 100%; height: 100%; object-fit: cover; display: block; }
#chat p.msg .msg-thumb.is-missing{ display: flex; align-items: center; justify-content: center; font-size: 22px; cursor: default; }
.capture-viewer{
  position: fixed; inset: 0; z-index: 100000; background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center; overflow: auto;
}
.capture-viewer img{ max-width: 100vw; max-height: 100vh; object-fit: contain; touch-action: pinch-zoom; }
.capture-viewer-close{
  position: fixed; top: 10px; right: 10px; width: 44px; height: 44px; border-radius: 22px;
  border: none; background: rgba(255,255,255,0.9); font-size: 20px; cursor: pointer;
}

/* POSTIT_DEUX_RUBRIQUES_02_10 */
#memory-postit .postit-section{ margin-top: 6px; }
#memory-postit .postit-muted{ opacity: .7; font-size: 11px; font-weight: normal; }

/* SELECTEUR_LANGUE_02_10 */
#alfred-lang-select{ flex: 0 0 auto; max-width: 84px; }
