/* Глобальный лайтбокс картинок (js/ac-lightbox.js). Не зависит от темы — всегда тёмный фон. */
.ac-lb {
  position: fixed;
  inset: 0;
  z-index: 10040; /* выше модалок островов, ниже тостов (10050) */
  display: flex;
  flex-direction: column;
  background: rgba(6, 8, 12, 0.92);
  color: #f1f5f9;
  opacity: 0;
  transition: opacity 0.15s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  font-family: var(--font, system-ui, sans-serif);
}
.ac-lb[hidden] { display: none; }
.ac-lb--open { opacity: 1; }

.ac-lb__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  min-height: 56px;
  box-sizing: border-box;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent);
  position: relative;
  z-index: 2;
}
.ac-lb__counter {
  flex: 0 0 auto;
  font-size: 13px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}
.ac-lb__counter:empty { display: none; }
.ac-lb__caption {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-lb__actions {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
}

.ac-lb__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.ac-lb__btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}
.ac-lb__btn:focus-visible {
  outline: 2px solid var(--accent, #60a5fa);
  outline-offset: 2px;
}
.ac-lb__btn[hidden] { display: none; }

.ac-lb__stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 64px 24px;
  box-sizing: border-box;
  overflow: hidden;
}
.ac-lb__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  user-select: none;
  -webkit-user-drag: none;
}
.ac-lb--zoomable .ac-lb__img { cursor: zoom-in; }

/* Реальный размер с прокруткой. */
.ac-lb--zoom .ac-lb__stage {
  overflow: auto;
  display: block;
  padding: 0 16px 16px;
  text-align: center;
}
.ac-lb--zoom .ac-lb__img {
  max-width: none;
  max-height: none;
  margin: 0 auto;
  cursor: zoom-out;
}

.ac-lb__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 44px;
  height: 64px;
  border-radius: 12px;
  font-size: 18px;
}
.ac-lb__prev { left: 10px; }
.ac-lb__next { right: 10px; }

.ac-lb__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ac-lb-spin 0.8s linear infinite;
  display: none;
}
.ac-lb--loading .ac-lb__spinner { display: block; }
.ac-lb--loading .ac-lb__img { opacity: 0; }
.ac-lb--error .ac-lb__stage::after {
  content: 'Не удалось загрузить изображение';
  position: absolute;
  font-size: 14px;
  opacity: 0.75;
}
.ac-lb--error .ac-lb__img { display: none; }
@keyframes ac-lb-spin { to { transform: rotate(360deg); } }

/* Курсор-подсказка на превью в чатах. */
a.tmd-file-img img,
.tasks-chat-msg-thumb > a img,
a[data-ac-lightbox] img { cursor: zoom-in; }

@media (max-width: 640px) {
  .ac-lb__bar { padding: 8px 8px 8px 12px; gap: 8px; }
  .ac-lb__btn { width: 36px; height: 36px; font-size: 15px; }
  .ac-lb__stage { padding: 0 8px 12px; }
  .ac-lb__nav { width: 36px; height: 52px; background: rgba(0, 0, 0, 0.45); }
  .ac-lb__prev { left: 4px; }
  .ac-lb__next { right: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .ac-lb { transition: none; }
  .ac-lb__spinner { animation-duration: 2s; }
}
