@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* NoteLab.cloud - Interface Hyper Notepad Ultra-Fidèle */

:root {
  --bg-app: #121316;
  --bg-sidebar: #17181c;
  --bg-editor: #0a0a0a;
  --border-color: #24262e;
  --border-subtle: #1e2026;

  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --hover-bg: rgba(255, 255, 255, 0.05);
  --active-bg: rgba(255, 255, 255, 0.08);

  --accent: #3b82f6;
  --btn-save-bg: #ffffff;
  --btn-save-text: #0f1117;
  --sidebar-item-gap: 3px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* -------------------------------------------------------------
   STYLE MODERNE DE LA BARRE DE SCROLL (Dark sleek design)
   ------------------------------------------------------------- */
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #2b2e38 transparent;
}

/* Chrome, Edge, Safari, Opera */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #252830;
  border-radius: 9999px;
  border: 1px solid transparent;
  background-clip: padding-box;
  transition: background-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: #3b82f6;
  /* Bleu vibrant NoteLab au survol */
}

::-webkit-scrollbar-thumb:active {
  background: #60a5fa;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

body,
input,
textarea,
select,
button {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

.app-wrapper {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* -------------------------------------------------------------
   1. SIDEBAR GAUCHE
   ------------------------------------------------------------- */
.sidebar {
  width: 270px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.25s ease, transform 0.25s ease;
  position: relative;
  z-index: 10;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  transform: translateX(-100%);
  border-right: none;
}

.sidebar-header {
  padding: 10px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-logo-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.brand-logo-icon {
  display: flex;
  gap: 3px;
  align-items: center;
}

.brand-logo-icon span {
  width: 4px;
  height: 16px;
  border-radius: 2px;
}

.brand-logo-icon span:nth-child(1) {
  background: #f97316;
  height: 12px;
}

.brand-logo-icon span:nth-child(2) {
  background: #3b82f6;
  height: 16px;
}

.brand-logo-icon span:nth-child(3) {
  background: #a855f7;
  height: 14px;
}

.brand-title {
  font-size: 0.96rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.01em;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.btn-icon-header {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.btn-icon-header:hover {
  background: var(--hover-bg);
  color: #fff;
}

/* Search bar */
.sidebar-search {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.search-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: #1c1d22;
  padding: 15px;
  gap: 0.5rem;
  transition: border-color 0.2s;
}

.search-input-wrapper:focus-within {
  border-color: #3b82f6;
}

.search-input-wrapper svg {
  color: var(--text-muted);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.search-input-wrapper input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.84rem;
  width: 100%;
}

.search-input-wrapper input::placeholder {
  color: var(--text-muted);
}

.btn-filter-sort {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 12px;
}

.btn-filter-sort:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.btn-filter-sort.active {
  background: var(--active-bg);
  color: #3b82f6;
}

.btn-filter-sort.is-filtered {
  color: #3b82f6 !important;
}

.btn-filter-sort.is-filtered svg {
  stroke: #3b82f6 !important;
}

.btn-filter-sort.is-filtered:hover {
  color: #60a5fa !important;
}

.btn-filter-sort.is-filtered:hover svg {
  stroke: #60a5fa !important;
}

/* Notes List */
.sidebar-notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 15px 0px;
  display: flex;
  flex-direction: column;
  gap: var(--sidebar-item-gap, 3px);
}

.sidebar-notes-list::-webkit-scrollbar {
  width: 5px;
}

.sidebar-notes-list::-webkit-scrollbar-thumb {
  background: #252730;
  border-radius: 4px;
}

/* Folder & Subfolder Tree Structure */
.folder-group {
  display: flex;
  flex-direction: column;
  user-select: none;
  position: relative;
  gap: var(--sidebar-item-gap, 3px);
}

.folder-row {
  margin-left: calc(var(--indent-level, 0) * 16px + 8px);
  margin-right: 8px;
  padding: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  border-left: 2px solid #3b82f6;
  background-color: #0e0e0e;
  gap: 6px;
  transition: background 0.15s, color 0.15s;
  color: var(--text-secondary);
  position: relative;
}

.folder-row:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.folder-row.active {
  background: var(--active-bg);
  color: #fff;
}

.folder-row.open {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.folder-row.open .folder-chevron {
  color: var(--text-primary);
}

.folder-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), color 0.15s;
  flex-shrink: 0;
}

.folder-row:hover .folder-chevron {
  color: var(--text-primary);
}

.folder-row.open .folder-chevron {
  transform: rotate(90deg);
}

.folder-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #3b82f6;
  flex-shrink: 0;
  transition: color 0.15s;
}

.folder-title {
  font-size: 0.84rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.folder-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: auto;
  padding-right: 2px;
  opacity: 0.7;
}

.folder-actions {
  display: none;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}

.folder-row:hover .folder-count {
  display: none;
}

.folder-row:hover .folder-actions {
  display: flex;
}

.btn-folder-action {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s;
}

.btn-folder-action:hover {
  color: #fff;
}

.folder-children {
  display: flex;
  flex-direction: column;
  position: relative;
  gap: var(--sidebar-item-gap, 3px);
}

.folder-children.collapsed {
  display: none;
}

/* Lignes guides d'arborescence avec arrondis au bas */
.folder-group.tree-branch:not(.tree-branch-last)::after {
  content: '';
  position: absolute;
  left: calc(var(--parent-level, 0) * 16px + 8px);
  top: 0;
  bottom: calc(-1 * var(--sidebar-item-gap, 3px) - 1px);
  border-left: 2px solid #3b82f6;
  pointer-events: none;
  z-index: 1;
}

.note-item.tree-branch:not(.tree-branch-last)::after {
  content: '';
  position: absolute;
  left: -16px;
  top: 0;
  bottom: calc(-1 * var(--sidebar-item-gap, 3px) - 1px);
  border-left: 2px solid #3b82f6;
  pointer-events: none;
  z-index: 1;
}

.folder-row.tree-branch::before {
  content: '';
  position: absolute;
  left: -18px;
  top: calc(-1 * var(--sidebar-item-gap, 3px));
  height: calc(16px + var(--sidebar-item-gap, 3px));
  width: 16px;
  border-left: 2px solid #3b82f6;
  border-bottom: 2px solid #3b82f6;
  border-bottom-left-radius: 10px;
  pointer-events: none;
  z-index: 2;
}

.note-item.tree-branch::before {
  content: '';
  position: absolute;
  left: -16px;
  top: calc(-1 * var(--sidebar-item-gap, 3px));
  height: calc(16px + var(--sidebar-item-gap, 3px));
  width: 14px;
  border-left: 2px solid #3b82f6;
  border-bottom: 2px solid #3b82f6;
  border-bottom-left-radius: 10px;
  pointer-events: none;
  z-index: 2;
}

/* Notes List Items */
.note-item {
  margin-left: calc(var(--indent-level, 0) * 16px + 8px);
  margin-right: 8px;
  padding: 5px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  transition: background 0.15s;
  position: relative;
}

.note-item:hover {
  background: var(--hover-bg);
}

.note-item.active {
  background: var(--active-bg);
}


.note-item.active .note-item-title {
  color: #fff;
}

.note-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color 0.15s;
}

.note-item:hover .note-item-icon {
  color: var(--text-secondary);
}


.note-item.active .note-item-icon {
  color: #60a5fa;
}

.note-item-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.btn-note-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  padding: 2px 4px;
  border-radius: 4px;
}

.note-item:hover .btn-note-delete {
  opacity: 1;
}

.btn-note-delete:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

.notes-empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* Drag and Drop Visual Feedback */
.drag-over {
  background: rgba(59, 130, 246, 0.18) !important;
  outline: 1px dashed #3b82f6 !important;
}

.is-dragging {
  opacity: 0.4;
}

/* Modal Déplacer */
.move-modal-dialog {
  max-width: 440px;
  width: 90%;
}

.move-folder-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sidebar-item-gap, 3px);
  margin: 1.2rem 0;
  padding: 4px 0;
  padding-right: 4px;
}

.move-folder-list::-webkit-scrollbar {
  width: 4px;
}

.move-folder-list::-webkit-scrollbar-thumb {
  background: #2b2d35;
  border-radius: 4px;
}

.move-folder-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: calc(var(--indent-level, 0) * 16px + 8px);
  margin-right: 8px;
  padding: 9px 12px;
  border-left: 2px solid #3b82f6;
  background-color: #0e0e0e;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  position: relative;
  transition: background 0.15s, color 0.15s;
}

.move-folder-item:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.move-folder-item.active {
  background: var(--active-bg);
  color: #fff;
}

.move-folder-item svg {
  color: #3b82f6;
  flex-shrink: 0;
}

/* Lignes guides d'arborescence pour les sous-dossiers dans le modal Déplacer */
.move-folder-item.tree-branch::before,
.move-folder-item[style*="--indent-level"]:not(.is-root)::before {
  content: '';
  position: absolute;
  left: -18px;
  top: calc(-1 * var(--sidebar-item-gap, 3px));
  height: calc(16px + var(--sidebar-item-gap, 3px));
  width: 16px;
  border-left: 2px solid #3b82f6;
  border-bottom: 2px solid #3b82f6;
  border-bottom-left-radius: 10px;
  pointer-events: none;
  z-index: 1;
}

.move-folder-item.is-root::before {
  display: none !important;
}

/* Sidebar Footer */
.sidebar-footer {
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-signin {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  border-right: 1px solid var(--border-color);
  padding: 15px;
  background: #22c55e;
  color: #000;
  font-size: 0.9em;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-signin:hover {
  background: #fff;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 11px;
  overflow: hidden;
}

.user-badge img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
}

.user-badge-name {
  font-size: 0.84rem;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 105px;
}

.btn-signout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: 2px;
}

.btn-signout:hover {
  color: #ef4444;
}

.footer-actions {
  display: flex;
  align-items: center;
}

.footer-icon-btn {
  background: none;
  border: none;
  background: #1c1d22;
  color: #fff;
  border-left: 1px solid var(--border-color);
  cursor: pointer;
  padding: 14px;
  margin: -1px;
  /* border-radius: 5px; */
  display: flex;
  align-items: center;
  justify-content: center;
}

.footer-icon-btn:hover {
  color: #fff;
  background: var(--hover-bg);
}

/* =============================================================
   MODE IFRAME / APERÇU INTÉGRÉ (.is-embedded)
   Désactive le lien NoteLab, le bouton Home et le bouton Déconnexion
   ============================================================= */
.is-embedded .brand-container {
  pointer-events: none !important;
  cursor: default !important;
  user-select: none;
}

.is-embedded .btn-signout,
.is-embedded .footer-icon-btn.btn-home {
  opacity: 0.28 !important;
  pointer-events: none !important;
  cursor: not-allowed !important;
  filter: grayscale(1) !important;
}

.is-embedded .btn-signout:hover {
  color: var(--text-muted) !important;
}

.is-embedded .footer-icon-btn.btn-home:hover {
  background: #1c1d22 !important;
  color: #fff !important;
}

/* -------------------------------------------------------------
   2. MAIN EDITOR PANEL
   ------------------------------------------------------------- */
.main-editor-pane {
  flex: 1;
  background-color: var(--bg-editor);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

/* Top Toolbar */
.editor-top-bar {
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-editor);
  z-index: 5;
}

.toolbar-group {
  display: flex;
  align-items: center;
}

.toolbar-btn {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  width: 37px;
  height: 37px;
  border-right: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1em;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.toolbar-btn:hover {
  background: var(--hover-bg);
  color: #fff;
}

.toolbar-btn.active {
  background: rgba(59, 130, 246, 0.18);
  color: #3b82f6;
}

.toolbar-btn svg {
  stroke: currentColor;
  flex-shrink: 0;
  transition: stroke 0.15s;
}

.toolbar-separator {
  width: 1px;
  height: 18px;
  background-color: var(--border-color);
  margin: 0 0.35rem;
  flex-shrink: 0;
}

/* =============================================================
   CUSTOM DROPDOWN (FORMAT & FONT FAMILY)
   ============================================================= */
.custom-dropdown-container {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.custom-dropdown-trigger {
  background: transparent;
  border: none;
  color: #d1d5db;
  border-right: 1px solid var(--border-color);
  font-size: 0.9em;
  font-weight: 500;
  font-family: inherit;
  padding: 10px;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.18s ease;
  user-select: none;
  white-space: nowrap;
}

.custom-dropdown-trigger:hover,
.custom-dropdown-container.open .custom-dropdown-trigger {
  background: var(--hover-bg);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.1);
}

.custom-dropdown-trigger .trigger-icon {
  color: #9ca3af;
  flex-shrink: 0;
}

.custom-dropdown-trigger:hover .trigger-icon,
.custom-dropdown-container.open .custom-dropdown-trigger .trigger-icon {
  color: #60a5fa;
}

.dropdown-chevron {
  color: #9ca3af;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.custom-dropdown-container.open .dropdown-chevron {
  transform: rotate(180deg);
  color: #60a5fa;
}

/* Menu déroulant flottant */
.custom-dropdown-menu {
  position: absolute;
  top: 100%;
  left: -1px;
  min-width: 240px;
  background: #17181c;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(14px);
  z-index: 1000;
  display: none;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.custom-dropdown-container.open .custom-dropdown-menu {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.dropdown-header-title {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 5px;
  color: #6b7280;
  user-select: none;
}

.dropdown-separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.07);
  margin: 0.3rem 0;
}

/* Éléments du menu */
.custom-dropdown-item {
  background: transparent;
  border: none;
  padding: 0.45rem 0.65rem;
  color: #e5e7eb;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  width: 100%;
  position: relative;
}

.custom-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.custom-dropdown-item.active {
  background: rgba(59, 130, 246, 0.14);
  color: #60a5fa;
}

.custom-dropdown-item .item-badge {
  width: 26px;
  height: 26px;
  min-width: 26px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.custom-dropdown-item:hover .item-badge {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.14);
}

.custom-dropdown-item.active .item-badge {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
  color: #60a5fa;
}

.custom-dropdown-item .item-badge svg {
  stroke: currentColor;
  display: block;
}

.custom-dropdown-item .item-font-preview {
  width: 26px;
  height: 26px;
  min-width: 26px;
  font-size: 0.9rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.custom-dropdown-item:hover .item-font-preview {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.14);
}

.custom-dropdown-item.active .item-font-preview {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
  color: #60a5fa;
}

.custom-dropdown-item.active .item-font-preview {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(59, 130, 246, 0.35);
  color: #60a5fa;
}

.custom-dropdown-item .item-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}

.custom-dropdown-item .item-title {
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.2;
}

.custom-dropdown-item .item-desc {
  font-size: 0.8rem;
  font-weight: 600;
  color: #6b7280;
  line-height: 1.1;
}

.custom-dropdown-item .item-check {
  margin-left: auto;
  color: #3b82f6;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.15s, transform 0.15s;
  flex-shrink: 0;
}

.custom-dropdown-item.active .item-check {
  opacity: 1;
  transform: scale(1);
}

/* Polices appliquées à l'éditeur */
.note-content-editor[data-font="inter"] {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
}

.note-content-editor[data-font="merriweather"] {
  font-family: 'Merriweather', Georgia, serif !important;
}

.note-content-editor[data-font="jetbrains-mono"] {
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace !important;
}

.note-content-editor[data-font="outfit"] {
  font-family: 'Outfit', 'Inter', sans-serif !important;
}

.note-content-editor[data-font="playfair"] {
  font-family: 'Playfair Display', Georgia, serif !important;
}

/* Actions à droite de la top-bar */
.editor-top-actions {
  display: flex;
  align-items: center;
  height: 37px;
  border-left: 1px solid var(--border-color);
}

.last-save-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8em;
  color: var(--text-muted);
  padding: 0 16px;
  user-select: none;
  white-space: nowrap;
}

.last-save-dot {
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background-color: #22c55e;
  display: inline-block;
  flex-shrink: 0;
}

span.last-save-label {
  font-weight: 500;
  font-size: 1em;
}

.last-save-status .last-save-time {
  color: #d1d5db;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
  .last-save-status .last-save-label {
    display: none;
  }
}

@media (max-width: 540px) {
  .last-save-status {
    display: none;
  }
}

/* Bouton Save Cloud avec effet upload vers la droite */
.btn-save-cloud {
  position: relative;
  overflow: hidden;
  background: #22c55e;
  color: #000;
  border: none;
  height: 37px;
  padding: 0 20px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-save-cloud .btn-save-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: #22c55e;
  z-index: 1;
  pointer-events: none;
  transition: width 1s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.btn-save-cloud .btn-save-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  pointer-events: none;
}

.btn-save-cloud:hover {
  opacity: 0.92;
}

.btn-save-cloud:active {
  transform: translateY(0);
}

/* Mode upload (chargement vers la droite) */
.btn-save-cloud.is-saving {
  background: #14532d;
  /* Fond de piste foncé pendant l'upload */
  cursor: not-allowed;
  pointer-events: none;
}

.btn-save-cloud.is-saving .btn-save-progress {
  background: linear-gradient(90deg, #16a34a 0%, #22c55e 90%, #86efac 100%);
  box-shadow: 2px 0 10px rgba(134, 239, 172, 0.7);
}

.btn-save-cloud.saved {
  background: #22c55e;
  color: #000;
}

.btn-save-cloud:disabled {
  cursor: not-allowed;
  pointer-events: none;
}

/* Writing Area */
.editor-scroll-area {
  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: #2b2e38 transparent;
}

.editor-scroll-area::-webkit-scrollbar {
  width: 8px;
}

.editor-scroll-area::-webkit-scrollbar-track {
  background: transparent;
}

.editor-scroll-area::-webkit-scrollbar-thumb {
  background: #252830;
  border-radius: 9999px;
  border: 1px solid transparent;
  background-clip: padding-box;
  transition: background-color 0.2s ease;
}

.editor-scroll-area::-webkit-scrollbar-thumb:hover {
  background: #3b82f6;
}

.editor-scroll-area::-webkit-scrollbar-thumb:active {
  background: #60a5fa;
}

.editor-workspace {
  flex: 1 0 auto;
  min-height: 100%;
  width: 100%;
  max-width: 900px;
  min-width: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 30px;
  position: relative;
  box-sizing: border-box;
  overflow-x: clip;
  border-left: 1px dashed var(--border-color);
  border-right: 1px dashed var(--border-color);
}

.note-title-input {
  background: none;
  border: none;
  outline: none;
  font-size: 1.85rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 1.25rem;
  font-family: inherit;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.note-title-input::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

.note-content-editor {
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  font-size: 1.05rem;
  line-height: 1.7;
  color: #d1d5db;
  text-align: left !important;
  min-height: 500px;
  user-select: text;
  tab-size: 4;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  box-sizing: border-box;
  position: relative;
}

/* Forcer l'alignement uniforme à gauche et le flux vertical ligne par ligne */
.note-content-editor * {
  max-width: 100% !important;
  box-sizing: border-box !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  text-align: left !important;
}

/* Neutralise les sous-scrollbars internes des éléments collés pour que seul le scroll global de la zone fonctionne */
.note-content-editor *:not(pre) {
  overflow: visible !important;
}

/* Empêche les div, cartes ou sections collées d'imposer un fond sombre ou un cadre rectangulaire */
.note-content-editor div,
.note-content-editor p,
.note-content-editor section,
.note-content-editor article,
.note-content-editor header,
.note-content-editor main,
.note-content-editor aside {
  background: transparent !important;
  background-color: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  height: auto !important;
  max-height: none !important;
  display: block !important;
  float: none !important;
  clear: both !important;
  width: 100% !important;
}

.note-content-editor p {
  margin: 0.35rem 0 !important;
  min-height: 1.5em !important;
  line-height: 1.7 !important;
}

/* Images responsives et personnalisables dans .editor-workspace */
.note-content-editor img {
  max-width: 100%;
  object-fit: contain;
  cursor: pointer;
  border-radius: 4px;
  user-select: none;
  transition: outline 0.15s ease;
}

.note-content-editor img:hover {
  outline: 2px solid rgba(59, 130, 246, 0.45);
  outline-offset: 1px;
}

.note-content-editor img.is-selected {
  outline: 2px solid #3b82f6 !important;
  outline-offset: 1px;
}

/* Modes de mise en page d'image (style Google Docs) */
.note-content-editor img[data-layout-mode="inline"] {
  display: inline-block;
  vertical-align: middle;
  float: none;
  margin: 4px 8px;
  position: static;
}

.note-content-editor img[data-layout-mode="wrap-left"] {
  display: inline-block;
  float: left;
  clear: none;
  margin: 8px 16px 8px 0;
  position: static;
}

.note-content-editor img[data-layout-mode="wrap-right"] {
  display: inline-block;
  float: right;
  clear: none;
  margin: 8px 0 8px 16px;
  position: static;
}

.note-content-editor img[data-layout-mode="break"] {
  display: block;
  float: none;
  clear: both;
}

.note-content-editor img[data-layout-mode="break"][data-align="left"],
.note-content-editor img[data-layout-mode="break"]:not([data-align]) {
  margin: 16px auto 16px 0 !important;
}

.note-content-editor img[data-layout-mode="break"][data-align="center"] {
  margin: 16px auto !important;
}

.note-content-editor img[data-layout-mode="break"][data-align="right"] {
  margin: 16px 0 16px auto !important;
}

.note-content-editor img[data-layout-mode="free"] {
  position: absolute !important;
  z-index: 15;
  margin: 0;
  float: none;
  cursor: grab;
}

.note-content-editor img[data-layout-mode="free"]:active {
  cursor: grabbing;
}

/* Neutralisation totale des tableaux collés : conversion en blocs verticaux 100% */
.note-content-editor table,
.note-content-editor thead,
.note-content-editor tbody,
.note-content-editor tr,
.note-content-editor th,
.note-content-editor td {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 0.2rem 0 !important;
  text-align: left !important;
}

/* Neutralise les positions fixes ou absolues qui feraient sortir le texte de .editor-workspace (sauf les images en mode libre) */
.note-content-editor *:not(img)[style*="fixed" i],
.note-content-editor *:not(img)[style*="Fixed"],
.note-content-editor *:not(img)[style*="sticky" i],
.note-content-editor *:not(img)[style*="absolute" i] {
  position: static !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
  transform: none !important;
}

.note-content-editor [style*="100vw" i],
.note-content-editor [style*="100vh" i] {
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
}

.note-content-editor iframe,
.note-content-editor frame,
.note-content-editor embed,
.note-content-editor object,
.note-content-editor script,
.note-content-editor style,
.note-content-editor form,
.note-content-editor button,
.note-content-editor input,
.note-content-editor select,
.note-content-editor textarea,
.note-content-editor canvas,
.note-content-editor svg:not(.safe-svg) {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.note-content-editor:empty:before {
  content: attr(placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

.note-content-editor ul {
  list-style-type: disc;
  padding-left: 2rem;
  margin: 0.6rem 0;
}

.note-content-editor ol {
  list-style-type: decimal;
  padding-left: 2rem;
  margin: 0.6rem 0;
}

.note-content-editor li {
  margin: 0.3rem 0;
  display: list-item;
}

.note-content-editor blockquote {
  border-left: 3px solid #3b82f6;
  background: rgba(59, 130, 246, 0.08);
  padding: 0.6rem 1.1rem;
  margin: 0.8rem 0;
  color: #9ca3af;
  border-radius: 0 8px 8px 0;
  font-style: italic;
}

.note-content-editor pre {
  background: #17181c;
  border: 1px solid #24262e;
  border-radius: 0px;
  padding: 0.85rem 1.1rem;
  font-size: 1rem;
  color: #38bdf8;
  overflow-x: auto;
  margin: 0.8rem 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.note-content-editor h1 {
  font-size: 1.85rem;
  font-weight: 700;
  color: #ffffff;
  margin: 1.2rem 0 0.5rem;
  line-height: 1.25;
}

.note-content-editor h2 {
  font-size: 1.45rem;
  font-weight: 600;
  color: #f3f4f6;
  margin: 1rem 0 0.4rem;
  line-height: 1.3;
}

.note-content-editor h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #e5e7eb;
  margin: 0.8rem 0 0.35rem;
  line-height: 1.35;
}

.note-content-editor p {
  margin: 0.4rem 0;
  min-height: 1.5em;
}

.note-content-editor a {
  color: #60a5fa;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.15s;
}

.note-content-editor a:hover {
  color: #93c5fd;
}

/* -------------------------------------------------------------
   3. MODAL DE CONNEXION GOOGLE (POPUP)
   ------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.modal-backdrop.open {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-dialog {
  background: #17181d;
  border: 1px solid var(--border-color);
  padding: 20px;
  max-width: 380px;
  text-align: center;
  position: relative;
}

.btn-close-modal {
  display: none;
}

.btn-close-modal:hover {
  color: #fff;
}

.modal-logo {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 1.25rem;
}

.modal-logo span {
  width: 5px;
  height: 20px;
  border-radius: 2px;
}

.modal-logo span:nth-child(1) {
  background: #f97316;
  height: 16px;
}

.modal-logo span:nth-child(2) {
  background: #3b82f6;
  height: 22px;
}

.modal-logo span:nth-child(3) {
  background: #a855f7;
  height: 18px;
}

.modal-title {
  font-size: 1.2em;
  font-weight: 500;
  color: #fff;
  margin-bottom: 10px;
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 1.8rem;
}

.google-btn-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 46px;
  margin-bottom: 0.75rem;
}

/* Option de session permanente / Rester connecté */
.auth-session-option {
  margin: 0.5rem 0 1.25rem;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  text-align: left;
}

.session-remember-label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  cursor: pointer;
  user-select: none;
}

.session-remember-label input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: #0f1117;
  border: 1px solid var(--border);
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  border-radius: 0;
  transition: all 0.15s ease;
}

.session-remember-label input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.session-remember-label input[type="checkbox"]:checked::before {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  transform: rotate(-45deg) translate(1px, -1px);
}

.session-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-text strong {
  font-size: 0.8rem;
  font-weight: 600;
  color: #f3f4f6;
  line-height: 1.3;
}

.session-text small {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.modal-footer-text {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* =============================================================
   MODALS PERSONNALISÉS (RENOMMER, SUPPRESSION, LIEN)
   ============================================================= */
.custom-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  box-sizing: border-box;
  animation: fadeIn 0.2s ease;
}

.custom-modal-backdrop.open {
  display: flex !important;
}

.custom-modal-dialog {
  background: #17181d;
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 440px;
  padding: 24px;
  position: relative;
  box-sizing: border-box;
  text-align: left;
}

.custom-modal-close {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 30px;
  height: 31px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
  line-height: 1;
  padding: 0;
}

.custom-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
}

.custom-modal-header {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  margin-bottom: 20px;
}

.custom-modal-icon-badge {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.custom-modal-icon-badge.danger {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.25);
}

.custom-modal-icon-badge.link-badge {
  background: rgba(14, 165, 233, 0.12);
  color: #38bdf8;
  border-color: rgba(14, 165, 233, 0.25);
}

.custom-modal-header-text {
  flex: 1;
  min-width: 0;
}

.custom-modal-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  margin: 0 0 3px 0;
  line-height: 1.3;
}

.custom-modal-subtitle {
  font-size: 0.8rem;
  color: #9ca3af;
  margin: 0;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-line;
}

.custom-modal-form {
  display: flex;
  flex-direction: column;
}

.custom-modal-field {
  margin-bottom: 16px;
}

.custom-modal-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: #d1d5db;
  margin-bottom: 6px;
}

.custom-modal-label .label-optional {
  color: #6b7280;
  font-size: 0.75rem;
  font-weight: 400;
  margin-left: 4px;
}

.custom-modal-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.custom-modal-input-wrapper .input-icon {
  position: absolute;
  left: 12px;
  color: #6b7280;
  pointer-events: none;
}

.custom-modal-input {
  width: 100%;
  background: #0d0f12;
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  font-size: 0.95rem;
  color: #fff;
  box-sizing: border-box;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.custom-modal-input::placeholder {
  color: #4b5563;
}

.custom-modal-input.has-icon {
  padding-left: 38px;
}

.custom-modal-input:focus {
  border-color: #3b82f6;
}

.custom-modal-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
}

.custom-modal-actions .modal-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-modal-cancel {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: #d1d5db;
  padding: 9px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.btn-modal-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.btn-modal-primary {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  padding: 9px 20px;
  font-size: 0.875rem;
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.btn-modal-danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #f87171;
  padding: 9px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}


.btn-modal-unlink {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  margin-right: auto;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.btn-modal-unlink:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.5);
}

/* =============================================================
   OUTIL SURLIGNAGE (TOOLBAR)
   ============================================================= */
.highlight-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.highlight-bar-indicator {
  position: absolute;
  bottom: 4px;
  width: 16px;
  height: 2.5px;
  border-radius: 1px;
  background-color: #facc15;
  pointer-events: none;
  transition: background-color 0.2s ease;
}

.highlight-menu {
  min-width: 200px;
  padding: 8px;
}

.highlight-colors-palette {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 4px 2px;
  grid-auto-flow: column;
}

.highlight-color-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  background: var(--c);
  cursor: pointer;
  outline: none;
  transition: transform 0.12s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.12s, box-shadow 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.highlight-color-btn:hover {
  border-color: #ffffff;
  z-index: 2;
}

.highlight-color-btn.clear-highlight {
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.3);
  color: #9ca3af;
}

.highlight-color-btn.clear-highlight:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #ef4444;
}

/* Styles pour le texte surligné dans l'éditeur */
.note-content-editor mark {
  background-color: rgba(250, 204, 21, 0.38);
  color: inherit;
  padding: 0.12em 0.25em;
  border-radius: 4px;
}

/* -------------------------------------------------------------
   BOUTON & PALETTE DE COULEUR DE TEXTE
   ------------------------------------------------------------- */
.text-color-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.text-color-letter-icon {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1;
  color: #f3f4f6;
  margin-top: -3px;
  pointer-events: none;
}

.text-color-bar-indicator {
  position: absolute;
  bottom: 4px;
  width: 16px;
  height: 2.5px;
  border-radius: 1px;
  background-color: #3b82f6;
  pointer-events: none;
  transition: background-color 0.2s ease;
}

.color-menu {
  min-width: 200px;
  padding: 8px;
}

.text-colors-palette {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 4px 2px;
}

.text-color-btn-item {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  background: var(--c);
  cursor: pointer;
  outline: none;
  transition: transform 0.12s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.12s, box-shadow 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.text-color-btn-item:hover {
  border-color: #ffffff;
  z-index: 2;
}

.text-color-btn-item.clear-text-color {
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.3);
  color: #9ca3af;
  font-size: 11px;
  font-weight: 700;
}

.text-color-btn-item.clear-text-color:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #ef4444;
}

/* -------------------------------------------------------------
   MENU DE TAILLE DE POLICE (FONT SIZE)
   ------------------------------------------------------------- */
.size-trigger {
  min-width: 68px;
  justify-content: space-between;
}

.size-trigger-icon {
  font-weight: 700;
  font-size: 0.86rem;
  color: #9ca3af;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.size-menu {
  min-width: 200px;
  max-height: 310px;
  overflow-y: auto;
  padding: 6px 0;
}

.size-menu::-webkit-scrollbar {
  width: 4px;
}

.size-menu::-webkit-scrollbar-thumb {
  background: #2b2d35;
  border-radius: 4px;
}

.item-size-preview {
  width: 26px;
  height: 26px;
  min-width: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #9ca3af;
  font-weight: 600;
  flex-shrink: 0;
}

.custom-dropdown-item:hover .item-size-preview {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.custom-dropdown-item.active .item-size-preview {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
  color: #60a5fa;
}

/* =============================================================
   MENU CONTEXTUEL CLIC DROIT (CUSTOM CONTEXT MENU)
   ============================================================= */
.notelab-context-menu {
  position: fixed;
  display: none;
  background: #17181c;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(20px);
  min-width: 220px;
  z-index: 9999;
  user-select: none;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  animation: ctxFadeIn 0.12s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ctxFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 6px 10px;
  color: #d1d5db;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.ctx-item:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
}

.ctx-item svg {
  color: #9ca3af;
  flex-shrink: 0;
  transition: color 0.12s;
}

.ctx-item:hover svg {
  color: #3b82f6;
}

.ctx-item-icon-text {
  width: 15px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #9ca3af;
  text-align: center;
  flex-shrink: 0;
}

.ctx-item:hover .ctx-item-icon-text {
  color: #3b82f6;
}

.ctx-shortcut {
  margin-left: auto;
  font-size: 0.72rem;
  color: #6b7280;
  font-weight: 400;
}

.ctx-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.07);
  margin: 4px 6px;
}

/* Rangée de surlignage dans le clic droit */
.ctx-highlight-row {
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ctx-highlight-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ctx-highlight-colors {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctx-color-dot {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  outline: none;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  flex-shrink: 0;
}

.ctx-color-dot:hover {
  border-color: #ffffff;
}

.ctx-color-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  color: #9ca3af;
  background: rgba(255, 255, 255, 0.06);
  border: 1px dashed rgba(255, 255, 255, 0.3);
}

.ctx-color-clear:hover {
  color: #ef4444;
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

.ctx-section {
  display: none;
}

.ctx-section.active {
  display: block;
}

.ctx-header-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: #9ca3af;
  padding: 6px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 230px;
}

.ctx-item.ctx-danger {
  color: #f87171;
}

.ctx-item.ctx-danger:hover {
  background: rgba(239, 68, 68, 0.14);
  color: #ef4444;
}

.ctx-item.ctx-danger svg {
  color: #f87171;
}

.ctx-item.ctx-danger:hover svg {
  color: #ef4444;
}

/* -------------------------------------------------------------
   POPOVERS D'INFORMATION ET PARAMÈTRES
   ------------------------------------------------------------- */
.notelab-popover {
  position: fixed;
  top: 37px;
  background: #17181c;
  border: 1px solid var(--border-color);
  padding: 16px;
  z-index: 10000;
  color: #f3f4f6;
  animation: notelabFadeIn 0.15s ease-out;
  min-width: 250px;
  max-width: 320px;
}

.notelab-popover-title {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notelab-popover-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  padding: 5px 0;
}

.notelab-popover-label {
  color: #9ca3af;
}

.notelab-popover-val {
  font-weight: 600;
  color: #f3f4f6;
}

.notelab-popover-btn {
  width: 100%;
  background: #24262e;
  border: none;
  border-radius: 6px;
  color: #f3f4f6;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.notelab-popover-btn:hover {
  background: #3b82f6;
  color: #ffffff;
}

/* Items du menu filtre / tri */
.notelab-filter-item {
  width: 100%;
  background: none;
  border: none;
  color: #d1d5db;
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  margin-top: 2px;
}

.notelab-filter-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.notelab-filter-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  font-weight: 600;
}

.notelab-filter-item .filter-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notelab-filter-item .filter-check {
  color: #3b82f6;
  flex-shrink: 0;
}

.notelab-filter-popover {
  top: 57px !important;
  left: 269px !important;
}

/* =============================================================
   INTERACTIVE IMAGE RESIZER & CONTROLS (GOOGLE DOCS STYLE)
   ============================================================= */
.notelab-image-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 50;
  transition: opacity 0.15s ease;
}

.image-overlay-box {
  position: absolute;
  inset: 0;
  border: 2px solid #3b82f6;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.image-overlay-drag-surface {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  cursor: move;
  display: none;
  background: rgba(59, 130, 246, 0.05);
}

.notelab-image-overlay[data-mode="free"] .image-overlay-drag-surface {
  display: block;
}

/* Poignées de redimensionnement */
.image-resize-handle {
  position: absolute;
  width: 9px;
  height: 9px;
  background: #ffffff;
  border: 1.5px solid #3b82f6;
  border-radius: 2px;
  pointer-events: auto;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.image-resize-handle.handle-nw {
  top: -5px;
  left: -5px;
  cursor: nwse-resize;
}

.image-resize-handle.handle-n {
  top: -5px;
  left: calc(50% - 4.5px);
  cursor: ns-resize;
}

.image-resize-handle.handle-ne {
  top: -5px;
  right: -5px;
  cursor: nesw-resize;
}

.image-resize-handle.handle-e {
  top: calc(50% - 4.5px);
  right: -5px;
  cursor: ew-resize;
}

.image-resize-handle.handle-se {
  bottom: -5px;
  right: -5px;
  cursor: nwse-resize;
}

.image-resize-handle.handle-s {
  bottom: -5px;
  left: calc(50% - 4.5px);
  cursor: ns-resize;
}

.image-resize-handle.handle-sw {
  bottom: -5px;
  left: -5px;
  cursor: nesw-resize;
}

.image-resize-handle.handle-w {
  top: calc(50% - 4.5px);
  left: -5px;
  cursor: ew-resize;
}

.image-resize-handle:hover {
  background: #3b82f6;
  transform: scale(1.2);
}

/* Badge de dimensions */
.image-size-badge {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: #17181c;
  color: #f3f4f6;
  border: 1px solid #2e323b;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.image-size-badge.visible {
  display: block;
}

/* Barre d'options style Google Docs */
.image-options-bar {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #17181c;
  border: 1px solid #2e323b;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
  pointer-events: auto;
  white-space: nowrap;
  z-index: 60;
  animation: notelabFadeIn 0.15s ease-out;
}

.image-mode-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.img-opt-btn {
  background: transparent;
  border: none;
  color: #9ca3af;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s ease;
  user-select: none;
}

.img-opt-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.img-opt-btn.active {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  font-weight: 600;
}

.img-opt-btn svg {
  stroke: currentColor;
  flex-shrink: 0;
}

.img-opt-divider {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 3px;
}

.image-align-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.img-opt-btn-icon {
  background: transparent;
  border: none;
  color: #9ca3af;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s ease;
}

.img-opt-btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.img-opt-btn-icon.active {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
}

.img-opt-btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}