/* Galeria visual por tópico/tema (js/lib/gallery.js) */
.gallery-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
  animation: gallery-fade 0.12s ease;
}
@keyframes gallery-fade { from { opacity: 0; } to { opacity: 1; } }
.gallery-modal {
  width: 100%;
  max-width: 1100px;
  height: min(700px, calc(100vh - 48px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--bg-1, #0f172a);
  border: 1px solid var(--border-soft, rgba(71, 85, 105, 0.5));
  border-radius: 14px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.gallery-modal.is-dropping { outline: 2px dashed var(--accent, #2edb7f); outline-offset: -8px; }
.gallery-modal--hub { max-width: 520px; }
.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle, rgba(71, 85, 105, 0.4));
}
.gallery-title {
  font: 600 15px/1.2 var(--font-sans, system-ui);
  color: var(--text-1, #e2e8f0);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.gallery-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-count { color: var(--text-3, #94a3b8); font-weight: 500; flex-shrink: 0; }
.gallery-head-actions { display: flex; gap: 8px; flex-shrink: 0; }
.gallery-btn {
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid var(--border-soft, rgba(71, 85, 105, 0.6));
  background: var(--bg-2, #1e293b);
  color: var(--text-1, #e2e8f0);
  font: 600 13px/1 var(--font-sans, system-ui);
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.gallery-btn:hover { background: var(--bg-3, #334155); }
.gallery-add { background: var(--accent, #2edb7f); color: #07210f; border-color: transparent; }
.gallery-add:hover { filter: brightness(1.08); background: var(--accent, #2edb7f); }
.gallery-close { padding: 7px 11px; }

.gallery-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
  align-items: start;
  align-content: start;
  gap: 14px;
  padding: 18px;
  outline: none;
}
.gallery-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-md, 12px);
  overflow: hidden;
  background: var(--bg-1, #1e293b);
  border: 1px solid var(--border-subtle, rgba(71, 85, 105, 0.4));
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.3));
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
  cursor: grab;
}
.gallery-cell:active { cursor: grabbing; }
.gallery-cell:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md, 0 6px 18px rgba(0, 0, 0, 0.35));
  border-color: var(--border-soft, rgba(100, 116, 139, 0.5));
}
.gallery-cell:focus-visible {
  outline: 2px solid var(--accent, #2edb7f);
  outline-offset: 2px;
}
/* Miniatura: altura fixa (grade alinhada). A imagem inteira aparece no lightbox. */
.gallery-cell-thumb {
  position: relative;
  height: 132px;
  background: var(--bg-0, #0f172a);
  overflow: hidden;
}
.gallery-cell-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
  display: block;
}
/* Rodapé: nome SEMPRE visível (fora da imagem), até 2 linhas, sem cortar no meio. */
.gallery-cell-foot {
  padding: 8px 10px;
  border-top: 1px solid var(--border-subtle, rgba(71, 85, 105, 0.4));
  background: var(--bg-1, #1e293b);
}
.gallery-cell-cap {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font: 500 12px/1.35 var(--font-sans, system-ui, sans-serif);
  color: var(--text-1, #e2e8f0);
  cursor: text;
  word-break: break-word;
}
.gallery-cell-cap.is-empty { color: var(--text-4, #64748b); font-style: italic; }
.gallery-cell-cap-input {
  width: 100%;
  box-sizing: border-box;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--accent, #2edb7f);
  background: var(--bg-0, #0f172a);
  color: var(--text-1, #e2e8f0);
  font: 500 12px/1.35 var(--font-sans, system-ui, sans-serif);
  outline: none;
}
/* Handle oculto (drag agora é pelo card inteiro) */
.gallery-cell-handle { display: none; }
.gallery-cell-num {
  position: absolute;
  top: 6px; left: 8px;
  z-index: 2;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: rgba(15, 23, 42, 0.82);
  color: #e2e8f0;
  font: 600 11px/20px var(--font-mono, ui-monospace, monospace);
  text-align: center;
}
/* Barra de ações no hover: ver / renomear / baixar / remover. */
.gallery-cell-actions {
  position: absolute;
  top: 6px; right: 6px;
  z-index: 3;
  display: flex;
  gap: 4px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.gallery-cell:hover .gallery-cell-actions,
.gallery-cell:focus-within .gallery-cell-actions { opacity: 1; transform: none; }
.gallery-cell-actions > * {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: none;
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.78);
  color: #e2e8f0;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease, filter 0.12s ease;
}
.gallery-cell-actions > *:hover { background: rgba(15, 23, 42, 0.95); filter: brightness(1.15); }
/* Remover (desvincula, mantém o arquivo salvo) fica neutro — quem é
   destrutivo de verdade é o apagar permanente logo ao lado. */
.gallery-cell-del-perm { color: #fca5a5; }
.gallery-cell-del-perm:hover { background: rgba(239, 68, 68, 0.32); color: #fecaca; }
.gallery-cell-dl.is-disabled { opacity: 0.4; pointer-events: none; }
/* Estados do SortableJS (espelha o padrão do kanban). */
.gallery-cell--ghost { opacity: 0.45; border: 1px dashed var(--accent, #2edb7f); }
.gallery-cell--chosen { box-shadow: var(--shadow-md, 0 6px 18px rgba(0, 0, 0, 0.4)); }
.gallery-cell--drag { box-shadow: var(--shadow-lg, 0 12px 32px rgba(0, 0, 0, 0.5)); transform: scale(1.02); }
.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-3, #94a3b8);
  font-size: 13px;
  line-height: 1.6;
  padding: 48px 16px;
}
.gallery-hint {
  margin: 0;
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle, rgba(71, 85, 105, 0.4));
  color: var(--text-3, #94a3b8);
  font-size: 12px;
}

/* Banner de configuração da pasta de imagens */
.gallery-setup {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 16px 0;
  padding: 12px 14px;
  background: rgba(46, 219, 127, 0.08);
  border: 1px solid rgba(46, 219, 127, 0.3);
  border-radius: 10px;
}
.gallery-setup[hidden] { display: none; }
.gallery-setup-msg { color: var(--text-2, #cbd5e1); font-size: 13px; line-height: 1.5; }
.gallery-setup-btn { flex-shrink: 0; }
.gallery-setup-btn[hidden] { display: none; }
.gallery-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent, #2edb7f);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}

/* Hub de temas */
.gallery-temas { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.gallery-tema-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 9px;
  border: 1px solid var(--border-subtle, rgba(71, 85, 105, 0.4));
  background: var(--bg-2, #1e293b);
  color: var(--text-1, #e2e8f0);
  font: 500 14px/1 var(--font-sans, system-ui);
  cursor: pointer;
  text-align: left;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.gallery-tema-row:hover { background: var(--bg-3, #334155); border-color: var(--border-soft, rgba(71, 85, 105, 0.6)); }
.gallery-tema-n { color: var(--text-3, #94a3b8); font-size: 12px; flex-shrink: 0; }

/* Lightbox */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  animation: gallery-fade 0.12s ease;
}
.gallery-lb-img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
  cursor: zoom-in;
}
.gallery-lb-img.is-zoomed { cursor: grab; }
.gallery-lb-img.is-grabbing { cursor: grabbing; }
.gallery-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 64px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.12s ease;
}
.gallery-lb-nav:hover { background: rgba(255, 255, 255, 0.18); }
.gallery-lb-prev { left: 18px; }
.gallery-lb-next { right: 18px; }
.gallery-lb-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}
.gallery-lb-close:hover { background: rgba(255, 255, 255, 0.18); }
.gallery-lb-card {
  position: absolute;
  top: 18px;
  left: 18px;
  border: none;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.9);
  color: #fff;
  font: 600 13px/1 var(--font-sans, sans-serif);
  padding: 0 14px;
  height: 42px;
  cursor: pointer;
  transition: background 0.12s ease, opacity 0.12s ease;
}
.gallery-lb-card:hover { background: rgba(79, 70, 229, 1); }
.gallery-lb-card:disabled { opacity: 0.6; cursor: default; }
.gallery-lb-top {
  position: absolute;
  top: 12px;
  left: 16px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;       /* dois "andares": título na 1ª linha, bolinhas na 2ª */
  align-items: flex-start;
  gap: 6px;
  max-width: min(640px, calc(100vw - 80px));
}
.gallery-lb-source {
  flex: 1 1 100%;        /* ocupa a linha inteira → bolinhas vão pro 2º andar */
  display: block;
  white-space: normal;   /* texto quebra normalmente em vez de ser truncado */
  overflow: visible;
  text-overflow: initial;
  color: #e2e8f0;
  font: 600 12.5px/1.45 var(--font-sans, system-ui, sans-serif);
  background: rgba(0, 0, 0, 0.62);
  padding: 6px 12px;
  border-radius: 10px;
  backdrop-filter: blur(8px);
}
.gallery-lb-context {
  flex: 0 0 auto;        /* nunca encolhe — sempre visível na 2ª linha */
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.55);
  color: var(--accent, #2edb7f);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 99px;
  cursor: pointer;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}
.gallery-lb-context:hover { background: rgba(46, 219, 127, 0.16); border-color: var(--accent, #2edb7f); }
/* Spinner de carregamento */
.gallery-lb-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent, #2edb7f);
  border-radius: 50%;
  animation: gallery-lb-spin 0.8s linear infinite;
  display: none;
  pointer-events: none;
}
.gallery-lightbox.is-loading .gallery-lb-spinner { display: block; }
@keyframes gallery-lb-spin { to { transform: rotate(360deg); } }

/* Faixa de cor por nível (classificação) no topo do card do tópico. */
.gallery-cell::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 0;
  z-index: 4;
}
.gallery-cell[data-nivel="1"]::before { height: 4px; background: #ef4444; }
.gallery-cell[data-nivel="2"]::before { height: 4px; background: #f59e0b; }
.gallery-cell[data-nivel="3"]::before { height: 4px; background: #22c55e; }
.gallery-cell[data-nivel="4"]::before { height: 4px; background: #3b82f6; }

/* Barra de níveis (cores) no lightbox — topo-centro. */
.gallery-lb-levels {
  position: absolute;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 10px;
  border-radius: 99px;
  backdrop-filter: blur(6px);
}
.gallery-lb-lvl {
  flex: 0 0 auto;        /* bolinhas nunca encolhem */
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--c, #64748b);
  cursor: pointer;
  padding: 0;
  opacity: 0.55;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.gallery-lb-lvl:hover { opacity: 1; transform: scale(1.12); }
.gallery-lb-lvl.is-on { opacity: 1; border-color: #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.55); }
.gallery-lb-lvl-clear {
  background: transparent;
  color: #cbd5e1;
  width: auto; height: 20px;
  border-radius: 99px;
  padding: 0 6px;
  font-size: 13px;
  opacity: 0.7;
}
.gallery-lb-lvl-clear:hover { opacity: 1; color: #fff; }

.gallery-lb-bottom {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(92vw, 720px);
  background: rgba(0, 0, 0, 0.65);
  padding: 10px 16px 12px;
  border-radius: 18px;
  backdrop-filter: blur(6px);
}
.gallery-lb-bottom-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.gallery-lb-counter {
  color: #cbd5e1;
  font: 500 13px/1 var(--font-mono, monospace);
  white-space: nowrap;
}
.gallery-lb-rename {
  display: flex;
  align-items: center;
  gap: 6px;
}
.gallery-lb-rename-ic { color: #94a3b8; font-size: 13px; }
.gallery-lb-name {
  width: min(48vw, 360px);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 99px;
  color: #f1f5f9;
  font-size: 13px;
  padding: 6px 12px;
  outline: none;
}
.gallery-lb-name:focus { border-color: var(--accent, #2edb7f); background: rgba(255, 255, 255, 0.12); }
.gallery-lb-name::placeholder { color: #94a3b8; }
.gallery-lb-save {
  border: none;
  border-radius: 99px;
  background: var(--accent, #2edb7f);
  color: #06240f;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 13px;
  cursor: pointer;
}
.gallery-lb-save:hover { filter: brightness(1.08); }
.gallery-lb-save:disabled { opacity: 0.6; cursor: default; }
.gallery-lb-saved { color: var(--accent, #2edb7f); font-size: 12px; font-weight: 600; white-space: nowrap; }

.gallery-lb-tags {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 7px;
  max-width: min(88vw, 690px);
  padding-top: 9px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.gallery-lb-tags-ic { color: #94a3b8; font-size: 12px; flex-shrink: 0; margin-top: 5px; }
.gallery-lb-tags-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.gallery-lb-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 9px;
  background: rgba(46, 219, 127, 0.14);
  border: 1px solid rgba(46, 219, 127, 0.3);
  border-radius: 999px;
  color: var(--accent, #2edb7f);
  font-size: 11.5px;
  font-weight: 500;
}
.gallery-lb-tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
}
.gallery-lb-tag-remove:hover { opacity: 1; background: rgba(255, 255, 255, 0.15); }
.gallery-lb-tags-inputwrap { position: relative; }
.gallery-lb-tags-input {
  width: 130px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: #f1f5f9;
  font-size: 11.5px;
  padding: 4px 10px;
  outline: none;
}
.gallery-lb-tags-input:focus { border-color: var(--accent, #2edb7f); background: rgba(255, 255, 255, 0.12); width: 170px; }
.gallery-lb-tags-input::placeholder { color: #94a3b8; }
.gallery-lb-tags-suggest {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 160px;
  max-width: 260px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1;
}
.gallery-lb-tags-suggest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: none;
  background: transparent;
  color: #e2e8f0;
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.gallery-lb-tags-suggest-item:hover { background: rgba(255, 255, 255, 0.1); }
.gallery-lb-tags-suggest-n { color: #94a3b8; font-size: 10.5px; }
.gallery-lb-zoom {
  position: absolute;
  bottom: 16px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.55);
  padding: 5px 6px;
  border-radius: 99px;
}
.gallery-lb-zoom button {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s ease;
}
.gallery-lb-zoom button:hover { background: rgba(255, 255, 255, 0.22); }
.gallery-lb-zlevel {
  min-width: 46px;
  text-align: center;
  color: #e5e7eb;
  font: 600 12px/1 var(--font-mono, monospace);
  user-select: none;
}

/* ── Botão de anotações (FAB) ───────────────────────────────────────────── */
.gallery-lb-notes-toggle {
  position: absolute;
  bottom: 80px;
  right: 18px;
  z-index: 6;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.18);
  background: rgba(10,17,35,0.78);
  color: #94a3b8;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.18s, border-color 0.18s, color 0.18s, box-shadow 0.18s;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
}
.gallery-lb-notes-toggle:hover {
  background: rgba(46,219,127,0.14);
  border-color: #2edb7f;
  color: #2edb7f;
  box-shadow: 0 0 0 3px rgba(46,219,127,0.12), 0 2px 12px rgba(0,0,0,0.35);
}
.gallery-lb-notes-toggle.is-active {
  background: rgba(46,219,127,0.2);
  border-color: #2edb7f;
  color: #2edb7f;
  box-shadow: 0 0 0 4px rgba(46,219,127,0.15), 0 2px 12px rgba(0,0,0,0.35);
}

/* ── Painel lateral de anotações ────────────────────────────────────────── */
.gallery-lb-notes-panel {
  position: absolute;
  top: 0; right: 0;
  width: clamp(300px, 36vw, 440px);
  height: 100%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  box-shadow: -4px 0 24px rgba(0,0,0,0.18);
  /* escondido por padrão — abre via .is-open */
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.26s cubic-bezier(0.32,0,0.16,1), opacity 0.22s ease;
}
.gallery-lb-notes-panel.is-open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* cabeçalho do painel — tema claro */
.gallery-lb-notes-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px 10px;
  border-bottom: 1px solid #e9edf2;
  flex-shrink: 0;
  background: #f8fafc;
}
.gallery-lb-notes-head-title {
  flex: 1;
  color: #64748b !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  letter-spacing: .05em !important;
  text-transform: uppercase !important;
}
.gallery-lb-notes-status {
  font-size: 11px;
  font-weight: 600;
  color: transparent;
  transition: color 0.2s;
  min-width: 44px;
  text-align: right;
}
.gallery-lb-notes-status.is-ok  { color: #16a34a; }
.gallery-lb-notes-status.is-err { color: #dc2626; }
.gallery-lb-notes-close {
  width: 26px; height: 26px;
  border: none;
  background: transparent;
  color: #94a3b8 !important;
  font-size: 14px !important;
  cursor: pointer;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
  line-height: 1;
}
.gallery-lb-notes-close:hover { background: #f1f5f9; color: #334155 !important; }

/* ── Toolbar de formatação — tema claro ─────────────────────────────────── */
.gallery-lb-notes-tb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 5px 8px 6px;
  border-bottom: 1px solid #e9edf2;
  flex-shrink: 0;
  background: #f8fafc;
}
.gallery-lb-notes-tb-group {
  display: flex;
  align-items: center;
  gap: 1px;
}
.gallery-lb-notes-tb-sep {
  width: 1px;
  height: 16px;
  background: #cbd5e1;
  margin: 0 3px;
  flex-shrink: 0;
  align-self: center;
}
/* reset completo — garante visibilidade independente de CSS global */
.gallery-lb-notes-tb-btn {
  all: unset !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 26px !important;
  height: 26px !important;
  padding: 0 4px !important;
  border-radius: 5px !important;
  cursor: pointer !important;
  font-family: var(--font-mono, monospace) !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  color: #64748b !important;
  background: transparent !important;
  border: none !important;
  transition: background 0.1s, color 0.1s !important;
  flex-shrink: 0 !important;
  line-height: 1 !important;
  white-space: nowrap !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}
.gallery-lb-notes-tb-btn:hover { background: #e9edf2 !important; color: #0f172a !important; }
.gallery-lb-notes-tb-btn:active { background: #dde3ea !important; }

/* variantes visuais dos botões */
.gallery-lb-notes-tb-btn--b  { font-weight: 900 !important; color: #1e293b !important; }
.gallery-lb-notes-tb-btn--i  { font-style: italic !important; color: #1e293b !important; }
.gallery-lb-notes-tb-btn--u  { text-decoration: underline !important; color: #1e293b !important; }
.gallery-lb-notes-tb-btn--s  { text-decoration: line-through !important; color: #1e293b !important; }
.gallery-lb-notes-tb-btn--h  { font-weight: 800 !important; font-size: 10.5px !important; color: #475569 !important; }
.gallery-lb-notes-tb-btn--hl { color: #ca8a04 !important; font-size: 12px !important; }
.gallery-lb-notes-tb-btn--code { font-size: 10px !important; color: #6366f1 !important; letter-spacing: -0.5px !important; }
.gallery-lb-notes-tb-btn--color { font-weight: 900 !important; color: #dc2626 !important; text-decoration: underline !important; text-decoration-color: #dc2626 !important; }
.gallery-lb-notes-tb-btn--bgcolor { color: #d97706 !important; font-size: 13px !important; }

/* ── Área de escrita ────────────────────────────────────────────────────── */
.gallery-lb-notes-editor {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 20px;
  color: #1e293b;
  font: 14.5px/1.75 var(--font-sans, system-ui, -apple-system, sans-serif);
  outline: none;
  min-height: 0;
  word-break: break-word;
  caret-color: #2563eb;
  background: #ffffff;
}
.gallery-lb-notes-editor:focus { outline: none; }
.gallery-lb-notes-editor:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  pointer-events: none;
  font-style: italic;
}
/* tipografia do editor */
.gallery-lb-notes-editor h1 { font-size: 1.35em; font-weight: 800; color: #0f172a; margin: .75em 0 .3em; line-height: 1.25; border-bottom: 2px solid #e2e8f0; padding-bottom: .2em; }
.gallery-lb-notes-editor h2 { font-size: 1.15em; font-weight: 700; color: #1e293b; margin: .6em 0 .2em; line-height: 1.35; }
.gallery-lb-notes-editor h3 { font-size: 1em;   font-weight: 700; color: #334155; margin: .5em 0 .15em; }
.gallery-lb-notes-editor p  { margin: .3em 0; }
/* Listas — !important sobrescreve reset do Tailwind (list-style:none, padding:0) */
.gallery-lb-notes-editor ul {
  list-style-type: disc !important;
  padding-left: 1.6em !important;
  margin: .35em 0 !important;
}
.gallery-lb-notes-editor ol {
  list-style-type: decimal !important;
  padding-left: 1.6em !important;
  margin: .35em 0 !important;
}
.gallery-lb-notes-editor li {
  display: list-item !important;
  margin: .18em 0 !important;
  padding-left: .2em !important;
}
/* listas aninhadas (Tab) */
.gallery-lb-notes-editor ul ul  { list-style-type: circle !important; margin-top: 0 !important; }
.gallery-lb-notes-editor ul ul ul { list-style-type: square !important; }
.gallery-lb-notes-editor ol ol  { list-style-type: lower-alpha !important; margin-top: 0 !important; }
.gallery-lb-notes-editor ol ol ol { list-style-type: lower-roman !important; }
.gallery-lb-notes-editor strong, .gallery-lb-notes-editor b { color: #0f172a; font-weight: 700; }
.gallery-lb-notes-editor em, .gallery-lb-notes-editor i { color: #334155; }
.gallery-lb-notes-editor code {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--font-mono, 'Fira Mono', monospace);
  font-size: .83em;
  color: #6366f1;
}
.gallery-lb-notes-editor pre {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  font-size: .85em;
  margin: .5em 0;
}
.gallery-lb-notes-editor blockquote {
  border-left: 3px solid #2563eb;
  margin: .5em 0;
  padding: 4px 0 4px 14px;
  color: #475569;
  font-style: italic;
  background: #f0f6ff;
  border-radius: 0 6px 6px 0;
}
.gallery-lb-notes-editor a { color: #2563eb; text-decoration: underline; }
.gallery-lb-notes-editor hr { border: none; border-top: 1px solid #e2e8f0; margin: 1em 0; }
/* scrollbar fina */
.gallery-lb-notes-editor::-webkit-scrollbar { width: 4px; }
.gallery-lb-notes-editor::-webkit-scrollbar-track { background: transparent; }
.gallery-lb-notes-editor::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ── Rodapé ─────────────────────────────────────────────────────────────── */
.gallery-lb-notes-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px 12px;
  border-top: 1px solid #e9edf2;
  flex-shrink: 0;
  background: #f8fafc;
}
.gallery-lb-notes-hint {
  flex: 1;
  font-size: 10.5px;
  color: #94a3b8;
  letter-spacing: .01em;
}
.gallery-lb-notes-save-btn {
  border: 1px solid rgba(37,99,235,0.3);
  background: rgba(37,99,235,0.08);
  color: #2563eb;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.gallery-lb-notes-save-btn:hover { background: rgba(37,99,235,0.14); border-color: rgba(37,99,235,0.5); }

/* ── Correção de resets globais de SVG ──────────────────────────────────── */
/* O flat.css (e Tailwind) podem zerar stroke-width ou forçar fill.
   Aqui sobrescrevemos com !important para os ícones do painel de anotações
   (mesmo padrão aplicado em .notas-editor-toolbar .notas-tb-btn svg). */
.gallery-lb-notes-tb-btn svg,
.gallery-lb-notes-toggle svg,
.gallery-lb-notes-head svg,
.gallery-lb-notes-close svg {
  display: block;
  fill: none !important;
  stroke: currentColor !important;
  stroke-width: 2 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
}
.gallery-lb-notes-tb-btn svg path,
.gallery-lb-notes-tb-btn svg line,
.gallery-lb-notes-tb-btn svg polyline,
.gallery-lb-notes-tb-btn svg circle,
.gallery-lb-notes-tb-btn svg rect,
.gallery-lb-notes-toggle svg path,
.gallery-lb-notes-toggle svg line,
.gallery-lb-notes-close svg line {
  stroke: currentColor !important;
  fill: none !important;
  stroke-width: inherit !important;
}

/* ----------------------------------------------------------------------
   Search picker (window.gallery.openSearchPicker) — busca em TODAS as
   imagens já existentes e vincula por toggle na galeria alvo, sem duplicar
   o arquivo. Compartilhado entre módulos (Cadernos, Editais, ...); dark,
   herda estilos de .galeria-card.
   ---------------------------------------------------------------------- */
.gallery-picker-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-picker-modal {
  background: #0f0f0f;
  border-radius: 14px;
  width: min(1100px, 96vw);
  height: min(700px, 92vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
}
.gallery-picker-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid #2a2a2a;
  flex-shrink: 0;
}
.gallery-picker-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #e8e8e8;
  white-space: nowrap;
  flex-shrink: 0;
}
.gallery-picker-search {
  flex: 1;
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 8px;
  color: #e8e8e8;
  font-size: 0.85rem;
  padding: 7px 12px;
  outline: none;
}
.gallery-picker-search:focus { border-color: #555; }
.gallery-picker-search::placeholder { color: #555; }
.gallery-picker-close {
  background: none;
  border: none;
  color: #888;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.gallery-picker-close:hover { background: #2a2a2a; color: #e8e8e8; }
/* Grid reutiliza .galeria-grid do galeria.css */
.gallery-picker-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  align-content: flex-start;
}
.gallery-picker-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid #2a2a2a;
  background: #0f0f0f;
  flex-shrink: 0;
  gap: 12px;
}
.gallery-picker-count {
  font-size: 0.82rem;
  color: #888;
  flex: 1;
}
.gallery-picker-confirm {
  height: 36px;
  padding: 0 20px;
  background: #15803d;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.gallery-picker-confirm:hover { background: #166534; }
/* No picker: thumb sem margem lateral (sem moldura de nível) */
.gallery-picker-grid .galeria-card-thumb {
  margin: 0;
  border-radius: 0;
  height: 150px;
}
/* Vinculada: borda verde */
.galeria-card.gallery-picker-is-linked {
  border-color: #15803d !important;
  background: rgba(21, 128, 61, 0.12) !important;
  cursor: pointer;
}
/* Badge ✓ sobre o thumb */
.gallery-picker-card-linked-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #15803d;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 5px;
  line-height: 1.4;
  z-index: 1;
}
/* Hover preview (grande, cobre metade da tela) */
.gallery-picker-hover-box {
  position: fixed;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  z-index: 9600;
  background: #0f0f0f;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 8px;
  pointer-events: none;
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.8);
  max-width: 48vw;
  max-height: 80vh;
}
.gallery-picker-hover-box.hidden { display: none; }
.gallery-picker-hover-img {
  display: block;
  max-width: 100%;
  max-height: 76vh;
  object-fit: contain;
  border-radius: 8px;
}
