/* Styles de la page Notes (#note-screen).
 * - Bandeau de recherche : même design que l’écran Employé (#gestion-compte-screen)
 *   — bandeau #3c4043, champ compact, focus doré (voir gestion-compte.css).
 * - Footer bas : même design que #photos-screen .photos-bottom-bar et
 *   #formulaire-screen .note-bottom-bar (fond translucide + blur, position
 *   fixe en bas, icônes centrées, état actif en bleu). */

/* Neutraliser le padding:24px et overflow:hidden du .screen de base pour
 * que le bandeau de recherche puisse toucher les bords de l'écran et que
 * le contenu commence juste sous le header fixe.
 *
 * NB : on NE ré-ajoute PAS env(safe-area-inset-top) ici car #app-container
 * (styles.css) applique déjà ce padding-top à toute l'app. Le header fixe
 * (position:fixed, top:env(safe-area-inset-top)) se place pile sous
 * l'encoche — il suffit donc de réserver la hauteur visible du header
 * (clamp ci-dessous), sinon on double la safe-area et un écart blanc
 * apparaît entre le header et le bandeau de recherche sur iPhone à
 * encoche, iPad, etc. */
#note-screen.note-has-bottom-bar.screen {
  padding: 0 !important;
  padding-top: clamp(48px, 12vw, 66px) !important;
  padding-bottom: 0 !important;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-x: hidden;
}

/* Réserver l'espace du footer fixe pour que le contenu ne passe pas dessous
 * (inclut la safe-area-inset-bottom iOS). */
#note-screen.note-has-bottom-bar .formulaire-main-feuille-temps {
  padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
}

/* La zone principale ne doit pas ajouter de padding horizontal qui empêcherait
 * le bandeau de recherche de toucher les bords de l'écran. Padding remis
 * plus bas sur le conteneur de liste pour conserver les gouttières des items. */
#note-screen .note-content,
#annonces-screen #annonces-panel-historique .note-content {
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
}

/* Gouttières pour la liste des notes (sans affecter le bandeau de recherche). */
#note-screen .note-list-container,
#annonces-screen #annonces-panel-historique .note-list-container {
  padding: 16px max(16px, env(safe-area-inset-right, 16px)) 16px max(16px, env(safe-area-inset-left, 16px));
}

/* Bandeau recherche Notes + Annonces (historique) : même chrome que Employé (#gestion-compte-screen). */
#note-screen .note-search-bg,
#annonces-screen #annonces-panel-historique .note-search-bg {
  flex-shrink: 0;
  height: 2px;
  width: 100%;
  background: #3c4043;
  pointer-events: none;
}

/* #projet-screen : bandeau noir (inchangé) — voir bloc dédié ci-dessous. */
#projet-screen .note-search-bg {
  flex-shrink: 0;
  height: 2px;
  width: 100%;
  background: #000;
  pointer-events: none;
}

#note-screen .note-search-wrap,
#annonces-screen #annonces-panel-historique .note-search-wrap {
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
  margin: 0;
  width: 100%;
  max-width: 100%;
  padding: 12px max(12px, env(safe-area-inset-right, 12px)) 12px max(12px, env(safe-area-inset-left, 12px));
  box-sizing: border-box;
  overflow: hidden;
  background: #3c4043;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

#note-screen .note-search-wrap .note-search-input,
#note-screen .note-search-wrap .gestion-compte-list-search,
#annonces-screen #annonces-panel-historique .note-search-wrap .note-search-input,
#annonces-screen #annonces-panel-historique .note-search-wrap .gestion-compte-list-search {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 0.9375rem;
  line-height: 1.35;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

#note-screen .note-search-wrap .note-search-input::placeholder,
#note-screen .note-search-wrap .gestion-compte-list-search::placeholder,
#annonces-screen #annonces-panel-historique .note-search-wrap .note-search-input::placeholder,
#annonces-screen #annonces-panel-historique .note-search-wrap .gestion-compte-list-search::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

#note-screen .note-search-wrap .note-search-input:focus,
#note-screen .note-search-wrap .gestion-compte-list-search:focus,
#annonces-screen #annonces-panel-historique .note-search-wrap .note-search-input:focus,
#annonces-screen #annonces-panel-historique .note-search-wrap .gestion-compte-list-search:focus {
  outline: none;
  border-color: rgba(253, 230, 138, 0.65);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
  background: rgba(255, 255, 255, 0.14);
}

#note-screen .note-search-wrap .gestion-compte-search-btn,
#annonces-screen #annonces-panel-historique .note-search-wrap .gestion-compte-search-btn {
  display: none;
}

/* #projet-screen : bandeau noir + champ « large » (inchangé vs ancien Notes) — voir #gestion-compte pour le style Employé. */
#projet-screen .note-search-wrap {
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
  margin: 0;
  width: 100%;
  max-width: 100%;
  padding: 14px max(12px, env(safe-area-inset-right, 12px)) 14px max(12px, env(safe-area-inset-left, 12px));
  box-sizing: border-box;
  overflow: hidden;
  background: #000;
}

#projet-screen .note-search-wrap .note-search-input,
#projet-screen .note-search-wrap .gestion-compte-list-search,
#projet-screen .note-search-wrap .projet-list-search {
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 1rem;
  line-height: 1.4;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

#projet-screen .note-search-wrap .note-search-input::placeholder,
#projet-screen .note-search-wrap .gestion-compte-list-search::placeholder,
#projet-screen .note-search-wrap .projet-list-search::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

#projet-screen .note-search-wrap .note-search-input:focus,
#projet-screen .note-search-wrap .gestion-compte-list-search:focus,
#projet-screen .note-search-wrap .projet-list-search:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
}

#note-screen .note-bottom-bar,
#projet-screen .note-bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  z-index: 999;
  flex-shrink: 0;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  padding-left: 0;
  padding-right: 0;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.08);
  margin: 0;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

#projet-screen .note-bottom-bar.projet-screen-footer {
  padding-top: 0;
}

#note-screen .note-bottom-bar .note-bottom-menu {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  width: 100%;
  padding: 0;
  background: transparent;
  border-radius: 0;
}

#projet-screen .note-bottom-bar .note-bottom-menu {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  width: 100%;
  padding: 0;
  background: transparent;
  border-radius: 0;
}

#note-screen .note-bottom-bar .note-menu-tab,
#projet-screen .note-bottom-bar .note-menu-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 6px 6px;
  border: none;
  background: transparent;
  color: var(--text-muted, #6b7280);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s, background 0.2s;
  min-width: 0;
  border-radius: 0;
}

#note-screen .note-bottom-bar .note-nav-icon,
#projet-screen .note-bottom-bar .note-nav-icon {
  font-size: 1.35rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#note-screen .note-bottom-bar .note-nav-icon svg,
#projet-screen .note-bottom-bar .note-nav-icon svg {
  width: 1.35rem;
  height: 1.35rem;
  min-width: 24px;
  min-height: 24px;
  flex-shrink: 0;
  color: inherit;
  stroke: currentColor;
}

#projet-screen .note-bottom-bar .note-nav-icon img {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

#note-screen .note-bottom-bar .note-nav-label,
#projet-screen .note-bottom-bar .note-nav-label {
  font-size: 0.7rem;
  font-weight: inherit;
  line-height: 1.2;
}

#note-screen .note-bottom-bar .note-menu-tab:active,
#projet-screen .note-bottom-bar .note-menu-tab:active {
  background: rgba(0, 0, 0, 0.04);
}

#note-screen .note-bottom-bar .note-menu-tab.active,
#projet-screen .note-bottom-bar .note-menu-tab.active {
  color: #2563eb;
  font-weight: 600;
}

@media (hover: hover) {
  #note-screen .note-bottom-bar .note-menu-tab:hover,
  #projet-screen .note-bottom-bar .note-menu-tab:hover {
    background: rgba(0, 0, 0, 0.03);
  }
}

/* Séparateur vertical discret entre Note et Partager. */
#note-screen .note-bottom-bar .note-menu-sep {
  flex: 0 0 auto;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--border, rgba(0, 0, 0, 0.12));
  font-size: 1.1rem;
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

/* Bouton « + » du header Notes : sans fond ni bordure (icône seule,
 * dans le ton du header). Override de l'apparence par défaut que le
 * navigateur applique sur les <button>. */
#note-screen #note-add-btn,
#note-screen #note-add-btn:hover,
#note-screen #note-add-btn:focus,
#note-screen #note-add-btn:active {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  color: inherit;
  cursor: pointer;
  outline: none;
}

/* Popover « + » du header Notes ET menu contextuel « … » de chaque note :
 * bandeau de titre avec fond doré (#c9a227 — même doré que l'app, utilisé
 * dans menu-popover.css) et texte noir pour un fort contraste. Scope sur
 * .note-add-popover / .note-item-popover pour ne pas affecter le popover
 * des notifications du tableau de bord (qui garde son titre gris). */
.note-add-popover.chat-unread-popover .chat-unread-popover-title,
.note-item-popover.chat-unread-popover .chat-unread-popover-title {
  background: #c9a227;
  color: #111827;
  border-bottom-color: rgba(0, 0, 0, 0.18);
}

/* Pas de petite flèche blanche au-dessus des popovers (héritée de
 * menu-popover.css via .chat-unread-popover::before). */
.note-add-popover.chat-unread-popover::before,
.note-item-popover.chat-unread-popover::before {
  content: none;
  display: none;
}

/* Thème nuit : même doré, texte noir conservé (bon contraste sur doré). */
#app-container.app-theme-night .note-add-popover.chat-unread-popover .chat-unread-popover-title,
#app-container.app-theme-night .note-item-popover.chat-unread-popover .chat-unread-popover-title {
  background: #c9a227;
  color: #111827;
  border-bottom-color: rgba(0, 0, 0, 0.25);
}

/* Action « Supprimer » du menu contextuel : texte rouge pour indiquer que
 * l'action est destructive. Survol rouge pâle + barre latérale rouge. */
.note-item-popover .chat-unread-popover-item[data-action="delete"] {
  color: #b91c1c;
}

.note-item-popover .chat-unread-popover-item[data-action="delete"]:hover {
  background: rgba(185, 28, 28, 0.08);
  border-left-color: #b91c1c;
}

#app-container.app-theme-night .note-item-popover .chat-unread-popover-item[data-action="delete"] {
  color: #fca5a5;
}

#app-container.app-theme-night .note-item-popover .chat-unread-popover-item[data-action="delete"]:hover {
  background: rgba(185, 28, 28, 0.22);
  border-left-color: #fca5a5;
}

/* Ligne de note : on force le contenu à prendre toute la largeur
 * disponible pour que le bouton « … » soit poussé complètement à droite
 * (margin-left:auto comme ceinture et bretelles). */
#note-screen .note-item .note-item-content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  overflow: hidden;
}

/* Titre sur une seule ligne : troncature avec « … » avant la zone date / menu,
 * sans que le texte s’approche ni passe sous l’icône épingle. */
#note-screen .note-item .formulaire-feuille-temps-item-label.note-item-title-line {
  /* Surcharge de feuille-temps.css (flex:1 sur le label) : ici le parent
   * est en colonne — sans ça, le titre s’étire sur toute la hauteur de la ligne. */
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

#note-screen .note-item .note-item-title-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sous le titre : contexte (avec / par / reçue de, etc.). Onglet
 * Partagées : 1re ligne = ce contexte ; 2e ligne = « Édité par … » seule. */
#note-screen .note-item .note-item-meta {
  display: block;
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--text-muted, #6b7280);
  word-break: break-word;
}

#note-screen .note-item .note-item-meta-line2 {
  font-size: 0.8rem;
  opacity: 0.95;
}

#note-screen .note-item .note-item-meta-line1 + .note-item-meta-line2 {
  margin-top: 4px;
}

#app-container.app-theme-night #note-screen .note-item .note-item-meta,
#app-container.app-theme-night #note-screen .note-item .note-item-meta-line2 {
  color: rgba(255, 255, 255, 0.65);
}

#note-screen .note-item .formulaire-feuille-temps-item-actions {
  margin-left: auto;
}

/* Notes épinglées : petit liseré doré à gauche + fond très légèrement
 * teinté pour signaler qu’elles sont remontées en tête de liste à cause
 * de l’épingle (et pas par activité récente). L’icône épingle dorée
 * apparaît juste avant le titre. */
#note-screen .note-item.note-item-pinned {
  border-left: 3px solid #c9a227;
  background: rgba(201, 162, 39, 0.06);
}

#app-container.app-theme-night #note-screen .note-item.note-item-pinned {
  background: rgba(201, 162, 39, 0.14);
}

#note-screen .note-item-pin-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  color: #c9a227;
  flex-shrink: 0;
  vertical-align: -2px;
}

#note-screen .note-item-pin-icon svg {
  width: 14px;
  height: 14px;
}

/* Date affichée à droite de chaque note, juste avant le bouton « … ».
 * Petit texte discret, aligné verticalement avec le bouton. Insécable
 * pour éviter que le jour se retrouve seul sur une ligne. */
#note-screen .note-item .formulaire-feuille-temps-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

#note-screen .note-item-date {
  font-size: 0.78rem;
  color: var(--text-muted, #6b7280);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

#app-container.app-theme-night #note-screen .note-item-date {
  color: rgba(255, 255, 255, 0.65);
}

/* Bouton « … » au bout de chaque note : remplace l'ancienne flèche ›.
 * Transparent par défaut, fond légèrement teinté au survol / focus. */
#note-screen .note-item-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted, #6b7280);
  border-radius: 8px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color 140ms ease, color 140ms ease;
  flex-shrink: 0;
}

#note-screen .note-item-more-btn:hover,
#note-screen .note-item-more-btn:focus-visible {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text, #111827);
  outline: none;
}

#note-screen .note-item-more-btn:active {
  background: rgba(0, 0, 0, 0.12);
}

#app-container.app-theme-night #note-screen .note-item-more-btn:hover,
#app-container.app-theme-night #note-screen .note-item-more-btn:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  color: #f3f4f6;
}

/* ─────────────────────────────────────────────────────────────────────
 * Écran d'édition de note (#note-edit-screen) — carte + éditeur riche
 * ───────────────────────────────────────────────────────────────────── */

#note-edit-screen.note-edit-screen {
  background: linear-gradient(165deg, #f4f6f9 0%, #e9edf3 48%, #eef1f6 100%);
}

#note-edit-screen .note-edit-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  padding: 10px max(12px, env(safe-area-inset-right, 12px)) 10px max(8px, env(safe-area-inset-left, 8px));
  min-height: 52px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow:
    inset 0 -2px 0 rgba(201, 162, 39, 0.35),
    0 8px 24px rgba(15, 23, 42, 0.06);
}

#note-edit-screen .note-edit-back-btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.04);
  transition: background 0.18s, transform 0.12s;
}

#note-edit-screen .note-edit-back-btn:active {
  transform: scale(0.96);
  background: rgba(201, 162, 39, 0.16);
}

#note-edit-screen .note-edit-header .formulaire-fill-back {
  grid-column: 1;
  justify-self: start;
  align-self: center;
}

#note-edit-screen .note-edit-header-title-wrap {
  grid-column: 2;
  justify-self: center;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  overflow: hidden;
}

#note-edit-screen .note-edit-header-title-wrap .formulaire-fill-title {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #111827;
}

#note-edit-screen .note-edit-source-line {
  margin: 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  line-height: 1.25;
  color: #64748b;
  text-align: center;
}

#note-edit-screen .note-edit-header-meta {
  grid-column: 3;
  justify-self: end;
  align-self: center;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 0;
}

#note-edit-screen .note-edit-updated {
  max-width: min(100%, 11rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72rem;
  line-height: 1.3;
  text-align: right;
  color: #64748b;
}

#note-edit-screen .note-realtime-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #166534;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(34, 197, 94, 0.28);
}

#note-edit-screen .note-realtime-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  animation: note-realtime-pulse 1.8s ease-out infinite;
}

@keyframes note-realtime-pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

#note-edit-screen .note-saved-indicator--header {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #1d4ed8;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.22);
}

#note-edit-screen .note-saved-indicator--header::before {
  content: '✓';
  font-size: 0.68rem;
  font-weight: 800;
}

#app-container.app-theme-night #note-edit-screen.note-edit-screen {
  background: linear-gradient(165deg, #0f1419 0%, #151b22 52%, #121820 100%);
}

#app-container.app-theme-night #note-edit-screen .note-edit-header {
  background: rgba(18, 24, 32, 0.92);
  border-bottom-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 -2px 0 rgba(201, 162, 39, 0.45),
    0 8px 24px rgba(0, 0, 0, 0.28);
}

#app-container.app-theme-night #note-edit-screen .note-edit-header-title-wrap .formulaire-fill-title {
  color: #f3f4f6;
}

#app-container.app-theme-night #note-edit-screen .note-edit-source-line,
#app-container.app-theme-night #note-edit-screen .note-edit-updated {
  color: rgba(255, 255, 255, 0.55);
}

#note-edit-screen.note-edit-screen--shared .note-edit-header-title-wrap .formulaire-fill-title {
  display: none;
}

#note-edit-screen.note-edit-screen--shared .note-edit-source-line {
  text-align: center;
  font-size: 0.88rem;
  font-weight: 600;
  color: #334155;
}

#note-edit-screen.note-edit-screen--shared .note-edit-header-meta {
  align-items: center;
  text-align: center;
  width: max-content;
  max-width: 100%;
}

#note-edit-screen.note-edit-screen--shared .note-edit-updated {
  text-align: center;
}

#note-edit-screen.note-edit-screen--shared .note-edit-title-wrap {
  display: none;
}

#note-edit-screen .note-edit-main {
  display: flex;
  flex-direction: column;
  padding: 12px max(12px, env(safe-area-inset-right, 12px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 12px));
  box-sizing: border-box;
}

#note-edit-screen .note-edit-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  gap: 10px;
}

#note-edit-screen .note-edit-sheet {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 14px 36px rgba(15, 23, 42, 0.08);
}

#note-edit-screen .note-edit-title-wrap {
  flex-shrink: 0;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  background: linear-gradient(180deg, rgba(201, 162, 39, 0.06) 0%, rgba(255, 255, 255, 0) 100%);
}

#note-edit-screen .note-edit-title-label {
  display: block;
  margin: 0 0 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
}

#note-edit-screen .note-edit-title-input {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: #0f172a;
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

#note-edit-screen .note-edit-title-input::placeholder {
  color: #cbd5e1;
  font-weight: 600;
}

#note-edit-screen .note-edit-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  overflow: hidden;
}

#note-edit-screen .note-edit-input {
  flex: 1;
  width: 100%;
  min-height: 120px;
  padding: 14px 16px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: #111827;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
}

#note-edit-screen .note-edit-content .tox-tinymce {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border: 0 !important;
  border-radius: 0 0 18px 18px !important;
  box-shadow: none !important;
}

#note-edit-screen .note-edit-content .tox-editor-header {
  border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
  box-shadow: none !important;
  background: #f8fafc !important;
}

#note-edit-screen .note-edit-content .tox-toolbar-overlord {
  flex-wrap: nowrap;
  padding: 2px 4px;
}

#note-edit-screen .note-edit-content .tox-toolbar__primary {
  background: transparent !important;
}

#note-edit-screen .note-edit-content .tox-tbtn {
  border-radius: 8px !important;
}

#note-edit-screen .note-edit-content .tox-tbtn--enabled,
#note-edit-screen .note-edit-content .tox-tbtn:hover {
  background: rgba(201, 162, 39, 0.14) !important;
}

#note-edit-screen .note-edit-content .tox-statusbar {
  border-top: 1px solid rgba(15, 23, 42, 0.08) !important;
  background: #f8fafc !important;
  border-radius: 0 0 18px 18px;
}

#note-edit-screen .note-edit-input::placeholder {
  color: #94a3b8;
}

#note-edit-screen .note-edit-input:focus {
  outline: none;
  border: 0;
  box-shadow: none;
}

#note-edit-screen .note-edit-message {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
  font-size: 0.82rem;
  font-weight: 600;
}

#app-container.app-theme-night #note-edit-screen .note-edit-sheet {
  background: #171d26;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
}

#app-container.app-theme-night #note-edit-screen .note-edit-title-wrap {
  border-bottom-color: rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(201, 162, 39, 0.1) 0%, rgba(23, 29, 38, 0) 100%);
}

#app-container.app-theme-night #note-edit-screen .note-edit-title-input {
  color: #f8fafc;
}

#app-container.app-theme-night #note-edit-screen .note-edit-content .tox-editor-header,
#app-container.app-theme-night #note-edit-screen .note-edit-content .tox-statusbar {
  background: #121820 !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

  margin: 0;
  font-size: 0.85rem;
  color: #b91c1c;
}

/* ─────────────────────────────────────────────────────────────────────
 * Modales « Transférer la note » (#note-transfer-modal), « Échanger
 * avec quel employé » (#note-share-modal), « Choisir un contrôleur »
 * (#dashboard-controleur-modal, plein écran — voir bloc dédié ci‑dessous) et modales clavardage (#chat-archive-empty-modal,
 * #chat-archived-list-modal, #chat-archived-view-modal) — même style que le popover
 * « Nouvelle note » : bandeau doré (#c9a227), texte noir, corps blanc
 * arrondi (sauf contrôleur), centrage viewport pour les cartes (modales enfants directs de #app-container).
 * ───────────────────────────────────────────────────────────────────── */
#note-transfer-modal .feuille-temps-modal-box,
#note-share-modal .feuille-temps-modal-box,
#chat-archive-empty-modal .feuille-temps-modal-box,
#chat-archived-list-modal .feuille-temps-modal-box,
#chat-archived-view-modal .feuille-temps-modal-box {
  max-width: 360px;
  padding: 0;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow:
    0 12px 32px rgba(15, 23, 42, 0.18),
    0 4px 10px rgba(15, 23, 42, 0.08);
  background: #ffffff;
}

/* Modal « Choisir un contrôleur » — plein écran (grille : backdrop + panneau même cellule). */
#dashboard-controleur-modal.feuille-temps-modal {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  align-items: stretch;
  justify-items: stretch;
  padding: 0;
  overflow: hidden;
  --feuille-temps-modal-top-clear: 0px;
  --feuille-temps-modal-bottom-clear: 0px;
}

#dashboard-controleur-modal .feuille-temps-modal-backdrop {
  grid-column: 1;
  grid-row: 1;
}

#dashboard-controleur-modal .feuille-temps-modal-box {
  grid-column: 1;
  grid-row: 1;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: none;
  background: #ffffff;
}

#note-transfer-modal .feuille-temps-projet-modal-header,
#note-share-modal .feuille-temps-projet-modal-header,
#chat-archive-empty-modal .feuille-temps-projet-modal-header,
#chat-archived-list-modal .feuille-temps-projet-modal-header,
#chat-archived-view-modal .feuille-temps-projet-modal-header {
  margin: 0;
  padding: 12px 14px 8px;
  background: #c9a227;
  border-bottom: 1px solid rgba(0, 0, 0, 0.18);
  gap: 8px;
}

#dashboard-controleur-modal .feuille-temps-projet-modal-header {
  margin: 0;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 14px));
  padding-bottom: 8px;
  padding-left: max(14px, env(safe-area-inset-left, 14px));
  background: #c9a227;
  border-bottom: 1px solid rgba(0, 0, 0, 0.18);
  gap: 8px;
}

#note-transfer-modal .feuille-temps-projet-modal-header h2,
#note-transfer-modal .feuille-temps-modal-title,
#note-share-modal .feuille-temps-projet-modal-header h2,
#note-share-modal .feuille-temps-modal-title,
#dashboard-controleur-modal .feuille-temps-projet-modal-header h2,
#dashboard-controleur-modal .feuille-temps-modal-title,
#chat-archive-empty-modal .feuille-temps-projet-modal-header h2,
#chat-archive-empty-modal .feuille-temps-modal-title,
#chat-archived-list-modal .feuille-temps-projet-modal-header h2,
#chat-archived-list-modal .feuille-temps-modal-title,
#chat-archived-view-modal .feuille-temps-projet-modal-header h2,
#chat-archived-view-modal .feuille-temps-modal-title {
  color: #111827;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

#note-transfer-modal .feuille-temps-projet-modal-header button,
#note-transfer-modal .feuille-temps-modal-close,
#note-share-modal .feuille-temps-projet-modal-header button,
#note-share-modal .feuille-temps-modal-close,
#dashboard-controleur-modal .feuille-temps-projet-modal-header button,
#dashboard-controleur-modal .feuille-temps-modal-close,
#chat-archive-empty-modal .feuille-temps-projet-modal-header button,
#chat-archive-empty-modal .feuille-temps-modal-close,
#chat-archived-list-modal .feuille-temps-projet-modal-header button,
#chat-archived-list-modal .feuille-temps-modal-close,
#chat-archived-view-modal .feuille-temps-projet-modal-header button,
#chat-archived-view-modal .feuille-temps-modal-close {
  width: 28px;
  height: 28px;
  color: #111827;
  border-radius: 8px;
}

#note-transfer-modal .feuille-temps-projet-modal-header button:hover,
#note-transfer-modal .feuille-temps-modal-close:hover,
#note-share-modal .feuille-temps-projet-modal-header button:hover,
#note-share-modal .feuille-temps-modal-close:hover,
#dashboard-controleur-modal .feuille-temps-projet-modal-header button:hover,
#dashboard-controleur-modal .feuille-temps-modal-close:hover,
#chat-archive-empty-modal .feuille-temps-projet-modal-header button:hover,
#chat-archive-empty-modal .feuille-temps-modal-close:hover,
#chat-archived-list-modal .feuille-temps-projet-modal-header button:hover,
#chat-archived-list-modal .feuille-temps-modal-close:hover,
#chat-archived-view-modal .feuille-temps-projet-modal-header button:hover,
#chat-archived-view-modal .feuille-temps-modal-close:hover {
  background: rgba(0, 0, 0, 0.12);
  color: #111827;
}

#note-transfer-modal .note-share-modal-desc,
#note-share-modal .note-share-modal-desc,
#dashboard-controleur-modal .note-share-modal-desc,
#chat-archive-empty-modal .note-share-modal-desc,
#chat-archived-list-modal .note-share-modal-desc,
#chat-archived-list-modal #chat-archived-list-body .note-share-modal-desc {
  margin: 0;
  padding: 14px 18px 0;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text, #1f2937);
}

#note-transfer-modal .input-group,
#note-share-modal .input-group,
#dashboard-controleur-modal .input-group {
  margin: 0;
  padding: 12px 18px 0;
}

#note-transfer-modal .input-group label,
#note-share-modal .input-group label,
#dashboard-controleur-modal .input-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted, #64748b);
  margin: 0 0 8px;
}

/* Liste déroulante : apparence type champ moderne, flèche custom (le select
 * natif a déjà appearance:none via feuille-temps.css dans les modals). */
#note-transfer-modal .note-share-select,
#note-share-modal .note-share-select,
#dashboard-controleur-modal .note-share-select {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 48px;
  padding: 12px 44px 12px 14px;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text, #0f172a);
  background-color: #f8fafc;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;
  border: 1.5px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

#note-transfer-modal .note-share-select:hover,
#note-share-modal .note-share-select:hover,
#dashboard-controleur-modal .note-share-select:hover {
  border-color: rgba(201, 162, 39, 0.5);
  background-color: #fff;
}

#note-transfer-modal .note-share-select:focus,
#note-share-modal .note-share-select:focus,
#dashboard-controleur-modal .note-share-select:focus {
  outline: none;
  border-color: #c9a227;
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.28);
  background-color: #fff;
}

#app-container.app-theme-night #note-transfer-modal .input-group label,
#app-container.app-theme-night #note-share-modal .input-group label,
#app-container.app-theme-night #dashboard-controleur-modal .input-group label {
  color: #94a3b8;
}

#app-container.app-theme-night #note-transfer-modal .note-share-select,
#app-container.app-theme-night #note-share-modal .note-share-select,
#app-container.app-theme-night #dashboard-controleur-modal .note-share-select {
  color: #f1f5f9;
  background-color: #0f172a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  border-color: rgba(255, 255, 255, 0.12);
}

#app-container.app-theme-night #note-transfer-modal .note-share-select:hover,
#app-container.app-theme-night #note-share-modal .note-share-select:hover,
#app-container.app-theme-night #dashboard-controleur-modal .note-share-select:hover {
  border-color: rgba(201, 162, 39, 0.55);
  background-color: #111827;
}

#app-container.app-theme-night #note-transfer-modal .note-share-select:focus,
#app-container.app-theme-night #note-share-modal .note-share-select:focus,
#app-container.app-theme-night #dashboard-controleur-modal .note-share-select:focus {
  background-color: #111827;
}

#note-transfer-modal .feuille-temps-modal-actions,
#note-transfer-modal .note-transfer-modal-actions,
#note-share-modal .feuille-temps-modal-actions,
#chat-archive-empty-modal .feuille-temps-modal-actions,
#chat-archive-confirm-modal .feuille-temps-modal-actions,
#chat-archived-list-modal .feuille-temps-modal-actions,
#chat-archived-view-modal .feuille-temps-modal-actions {
  margin: 0;
  padding: 14px 18px 18px;
}

/* Plein écran — marges latérales / pied avec encoche (après règles groupées). */
#dashboard-controleur-modal .note-share-modal-desc {
  padding-left: max(18px, env(safe-area-inset-left, 18px));
  padding-right: max(18px, env(safe-area-inset-right, 18px));
}

#dashboard-controleur-modal .input-group {
  padding-left: max(18px, env(safe-area-inset-left, 18px));
  padding-right: max(18px, env(safe-area-inset-right, 18px));
}

#dashboard-controleur-modal .feuille-temps-modal-actions {
  flex-shrink: 0;
  margin-top: auto;
  margin-bottom: 0;
  padding-top: 14px;
  padding-left: max(18px, env(safe-area-inset-left, 18px));
  padding-right: max(18px, env(safe-area-inset-right, 18px));
  padding-bottom: max(18px, env(safe-area-inset-bottom, 18px));
}

#app-container.app-theme-night #note-transfer-modal .feuille-temps-modal-box,
#app-container.app-theme-night #note-share-modal .feuille-temps-modal-box,
#app-container.app-theme-night #chat-archive-empty-modal .feuille-temps-modal-box,
#app-container.app-theme-night #chat-archive-confirm-modal .feuille-temps-modal-box,
#app-container.app-theme-night #chat-archived-list-modal .feuille-temps-modal-box,
#app-container.app-theme-night #chat-archived-view-modal .feuille-temps-modal-box {
  background: #1f2937;
  border-color: rgba(255, 255, 255, 0.06);
}

#app-container.app-theme-night #dashboard-controleur-modal .feuille-temps-modal-box {
  background: #1f2937;
  border-color: rgba(255, 255, 255, 0.06);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}
#app-container.app-theme-night #note-transfer-modal .note-share-modal-desc,
#app-container.app-theme-night #note-share-modal .note-share-modal-desc,
#app-container.app-theme-night #dashboard-controleur-modal .note-share-modal-desc,
#app-container.app-theme-night #chat-archive-empty-modal .note-share-modal-desc,
#app-container.app-theme-night #chat-archive-confirm-modal .note-share-modal-desc,
#app-container.app-theme-night #chat-archived-list-modal .note-share-modal-desc,
#app-container.app-theme-night #chat-archived-list-modal #chat-archived-list-body .note-share-modal-desc {
  color: #e5e7eb;
}

/* Clavardage : liste scrollable + lecture d’une archive (bulles) */
#chat-archived-list-modal .feuille-temps-modal-box.chat-archived-feuille-modal-box,
#chat-archived-view-modal .feuille-temps-modal-box.chat-archived-feuille-modal-box {
  display: flex;
  flex-direction: column;
  max-height: min(70vh, calc(100svh - 120px));
  min-height: 0;
}
#chat-archived-list-modal #chat-archived-list-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 4px;
}
#chat-archived-list-modal #chat-archived-list-body .chat-archived-list {
  margin: 0;
  padding: 0 8px 8px;
}
#chat-archived-view-modal #chat-archived-view-messages {
  flex: 1;
  min-height: 120px;
  max-height: min(40vh, 360px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
}
#chat-archived-view-modal #chat-archived-view-messages .chat-msg {
  max-width: 90%;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  font-size: 0.9rem;
}
#chat-archived-view-modal #chat-archived-view-messages .chat-msg.user > .chat-msg-column > .chat-msg-content {
  background: #0a0a0a;
  color: #fff;
  align-self: flex-end;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 12px;
}
#chat-archived-view-modal #chat-archived-view-messages .chat-msg.user {
  align-self: flex-end;
}
#chat-archived-view-modal #chat-archived-view-messages .chat-msg.assistant {
  align-self: flex-start;
  background: transparent;
  border: none;
}
#chat-archived-view-modal #chat-archived-view-messages .chat-msg.assistant > .chat-msg-column > .chat-msg-content {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text, #1f2937);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: 10px;
  padding: 8px 12px;
}
#app-container.app-theme-night #chat-archived-view-modal #chat-archived-view-messages .chat-msg.assistant > .chat-msg-column > .chat-msg-content {
  background: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
  border-color: rgba(255, 255, 255, 0.1);
}
#chat-archived-view-modal #chat-archived-view-messages .chat-msg-meta {
  font-size: 0.65rem;
  color: rgba(100, 116, 139, 0.95);
}
#chat-archived-view-modal #chat-archived-view-messages .chat-msg.user .chat-msg-meta {
  justify-content: flex-end;
}
#chat-archived-view-modal #chat-archived-view-messages .chat-msg.assistant .chat-msg-meta {
  justify-content: flex-start;
}
#chat-archived-list-modal .feuille-temps-projet-modal-header .feuille-temps-modal-title,
#chat-archived-view-modal .feuille-temps-projet-modal-header .feuille-temps-modal-title {
  flex: 1;
  min-width: 0;
}
#chat-archived-view-modal .feuille-temps-projet-modal-header .feuille-temps-modal-title {
  text-transform: none;
  font-size: 0.8rem;
  line-height: 1.3;
  font-weight: 700;
  word-break: break-word;
}
#chat-archived-list-modal .chat-archived-modal-header-actions,
#chat-archived-view-modal .chat-archived-modal-header-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 4px;
}
#chat-archived-list-modal .chat-archived-modal-nav,
#chat-archived-view-modal .chat-archived-modal-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}
#chat-archived-list-modal .chat-archived-modal-nav-btn,
#chat-archived-view-modal .chat-archived-modal-nav-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #111827;
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
#chat-archived-list-modal .chat-archived-modal-nav-btn:hover:not(:disabled),
#chat-archived-view-modal .chat-archived-modal-nav-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.12);
  color: #111827;
}
#chat-archived-list-modal .chat-archived-modal-nav-btn:disabled,
#chat-archived-view-modal .chat-archived-modal-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Affichage HTML des notes (vue lecture + contenu riche) */
.note-view-html {
  padding: 16px max(16px, env(safe-area-inset-right, 16px)) 16px max(16px, env(safe-area-inset-left, 16px));
  font-size: 1rem;
  line-height: 1.55;
  word-break: break-word;
}

.note-view-html img {
  max-width: 100%;
  height: auto;
}

.note-view-html table {
  width: 100%;
  border-collapse: collapse;
}

.note-view-html table td,
.note-view-html table th {
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 6px 8px;
}

.note-view-html pre {
  overflow-x: auto;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(127, 127, 127, 0.12);
}

.note-view-empty {
  padding: 16px;
  color: var(--text-muted, #6b7280);
}
