body {
  margin: 0;
  background: #111;
  display: flex;
  height: 100vh;
  font-family: 'Exo 2', system-ui, sans-serif;
  overflow-x: hidden;
  position: relative;
}

.container {
  position: relative;

  display: flex;
  justify-content: center;
  align-items: center;

  width: 100%;
  height: 100%;
}

#atlas_page_image {
  max-width: 100%;
  max-height: 95vh;

  width: auto;
  height: auto;

  display: block;

  transform-origin: center center;
  will-change: transform;
}

/* ЛИНЗА */
.img-magnifier-glass {
  position: fixed;

  width: min(330px, 45vw);
  height: min(330px, 45vw);

  border-radius: 50%;
  overflow: hidden;

  pointer-events: none;
  z-index: 100;

  border: 4px solid rgba(0, 0, 0, 0.6);

  box-shadow:
    0 0 30px rgba(0, 0, 0, 0.6),
    inset 0 20px 40px rgba(255, 255, 255, 0.2),
    inset 0 -20px 40px rgba(0, 0, 0, 0.35);

  background-color: rgba(255, 255, 255, 0.03);

  transform: translate(-50%, -50%);
  transition: transform 0.2 ease;
}

.img-magnifier-glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle,
      transparent 60%,
      rgba(0, 0, 0, 0.25));
}

.container {
  overflow: visible;
  position: relative;
}

.img-magnifier-glass::after {
  content: "";
  position: absolute;
  top: 10%;
  left: 15%;
  width: 40%;
  height: 30%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.15), transparent);
  border-radius: 50%;
  opacity: 0.25;
}

.img-magnifier-inner {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

/* Общая сетка */
.layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: #131518;
  color: #fff;
  padding: 20px 15px;

  position: fixed;
  left: 0;
  top: 0;
  height: 100dvh;

  display: flex;
  flex-direction: column;
  /* 🔥 важно */

  overflow: hidden;
  /* ❗ теперь не скроллится */
}

.sidebar-title {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 15px;
}

.back-container {
  text-align: center;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  margin-bottom: 10px;

  border-radius: 12px;

  color: white;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;

  background: #3b82f6;
  backdrop-filter: blur(6px);

  transition: 0.25s ease;
}

/* hover */
@media (hover: hover) {
  .back-btn:hover {
    background: #2563eb;
  }

  .back-btn:hover .back-arrow {
    transform: translateX(-4px) rotate(45deg);
    /* 🔥 сначала translate */
  }
}

/* mobile */
@media (max-width: 600px) {
  .back-btn {
    font-size: 14px;
    padding: 8px 14px;
  }
}

/* Список */
.atlas-list {
  display: flex;
  flex-direction: column;
  gap: 6px;

  overflow-y: auto;
  height: 100dvh;
  /* регулируй под высоту header */

  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.atlas-row {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: #cbd5f5;
  padding: 8px 10px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

/* Hover */
.atlas-row:hover {
  background: #1e293b;
  color: #fff;
}

/* Активная страница */
.atlas-row.active {
  background: #3b82f6;
  color: #fff;
  font-weight: bold;
}

/* Текст */
.atlas-page {
  white-space: nowrap;
}

.atlas-dots {
  flex: 1;
  border-bottom: 1px dotted #64748b;
  margin: 0 8px;
}

.atlas-label {
  font-size: 12px;
  opacity: 0.7;
}

/* Контент */
.content {
  flex: 1;
  position: relative;

  display: flex;
  flex-direction: column;
  /* ✅ добавили */
  justify-content: center;
  align-items: center;

  padding: 20px;
  margin-left: 260px;
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}

.container img {
  width: auto;
  height: auto;

  object-fit: contain;

  display: block;
}

@media (pointer: fine) {
  .container img {
    transition:
      width 0.25s ease,
      height 0.25s ease;
  }
}

/* 📱 Мобильная адаптация */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    transform: translateX(-100%);
    z-index: 1000;
    width: 260px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content {
    padding: 10px;
    margin-left: 0;
    padding-bottom: calc(140px + env(safe-area-inset-bottom));
  }
}

.menu-toggle {
  display: none;
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1100;

  background: transparent;
  /* убрали фон */
  color: #e5e7eb;

  border: none;
  padding: 8px;
  font-size: 22px;
  cursor: pointer;
}

/* показываем только на мобиле */
@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }
}

/* ===== СКРОЛЛБАР ===== */
.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-track {
  background: #080a0e;
}

.sidebar::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #1a1c1f, #1e293b);
  border-radius: 10px;
  border: 2px solid #0f172a;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #21262c, #334155);
}

/* Firefox */
.sidebar {
  scrollbar-width: thin;
  scrollbar-color: rgb(50, 55, 63) #0f172a;
}

.menu-toggle {
  transition: transform 0.2s ease;
}

.menu-toggle:active {
  transform: scale(0.9);
}

@media (max-width: 768px) {
  .menu-toggle {
    left: 10px;
    /* можно даже 5px при желании */
  }

  .sidebar-title {
    margin-left: 35px;
  }
}

.menu-toggle {
  -webkit-tap-highlight-color: transparent;
  /* убирает синий флэш на iOS/Android */
  outline: none;
}

.menu-toggle:focus,
.menu-toggle:active {
  outline: none;
  box-shadow: none;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 900;

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay.active {
  opacity: 1;
  pointer-events: all;
}

.container {
  overflow: hidden;
  touch-action: none;
}

.bottom-actions {
  display: flex;
  justify-content: center;
  max-width: calc(100% - 120px);
  /* ✅ центр */
  align-items: center;

  gap: 10px;
  margin-top: 12px;

  width: 100%;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

/* кнопки */
.action-btn {
  width: auto;
  /* ✅ убрали растягивание */
  box-sizing: border-box;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 8px 14px;
  /* чуть меньше */
  font-size: 13px;
  white-space: nowrap;

  text-align: center;
  text-decoration: none;

  color: #cbd5f5;
  background: rgba(15, 23, 42, 0.7);

  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;

  backdrop-filter: blur(10px);

  transition: all 0.2s ease;
}

/* hover */
.action-btn:hover {
  background: #1e293b;
  color: #fff;
  transform: translateY(-2px);
}

/* основная кнопка */
.action-btn.primary {
  background: #3b82f6;
  color: white;
  border: none;
}

.action-btn.primary:hover {
  background: #2563eb;
}

/* --- ДОБАВЛЕНО: десктоп поведение --- */
@media (min-width: 769px) {
  .bottom-actions {
    flex-direction: row;
    /* ✅ в строку */
  }

  .action-btn {
    width: auto;
  }
}

@media (min-width: 769px) {
  .content {
    height: 100vh;
    box-sizing: border-box;
    padding: 20px 20px 60px;
    /* учитываем кнопки снизу */
  }

  .container {
    height: 100%;
    max-height: 100%;
  }

  #atlas_page_image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
}

@media (max-width: 768px) {
  .bottom-actions {
    position: fixed;
    bottom: calc(15px + env(safe-area-inset-bottom));

    left: 60px;
    /* 👈 отступ под левое ухо */
    right: 60px;
    /* 👈 под правое */

    padding: 0 10px;

    display: flex;
    flex-direction: column;
    gap: 10px;

    z-index: 800;
    box-sizing: border-box;
  }

  .action-btn {
    width: 100%;
    box-sizing: border-box;
    /* ✅ чтобы padding не ломал ширину */
  }

  .zoom-description {
    display: none;
  }
}

.zoom-description {
  color: white;
}

.action-btn::before {
  margin-right: 6px;
}

.action-btn:not(.primary)::before {
  content: "↗";
}

.action-btn.primary::before {
  content: "↓";
}

.side-nav {
  position: fixed;
  bottom: calc(15px + env(safe-area-inset-bottom));

  width: 48px;
  height: 80px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(10px);

  border: 1px solid rgba(255, 255, 255, 0.08);

  z-index: 850;
  transition: all 0.2s ease;
}

/* левая */
.side-nav.left {
  left: 0;
  border-radius: 0 12px 12px 0;
}

/* правая */
.side-nav.right {
  right: 0;
  border-radius: 12px 0 0 12px;
}

.side-nav a,
.side-nav span {
  color: #cbd5f5;
  font-size: 22px;
  text-decoration: none;
}

/* hover */
@media (hover: hover) {
  .side-nav:hover {
    background: #1e293b;
    transform: scale(1.05);
  }
}

/* disabled */
.side-nav.disabled {
  opacity: 0.3;
  pointer-events: none;
}

@media (min-width: 769px) {
  .side-nav {
    display: none;
  }
}

.side-nav,
.side-nav a,
.action-btn {
  -webkit-tap-highlight-color: transparent;
}

.side-nav a,
.action-btn {
  outline: none;
}

.side-nav a:focus,
.action-btn:focus {
  outline: none;
  box-shadow: none;
}

.side-nav,
.side-nav a,
.action-btn {
  user-select: none;
  -webkit-user-select: none;
}

.sidebar-header {
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;

  background: #131518;
  /* важно — чтобы не просвечивал */
  padding-bottom: 10px;
}

/* ===== ROTATE HINT ===== */

.rotate-hint {
  position: fixed;

  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);

  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px 14px;

  border-radius: 14px;

  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(14px);

  border: 1px solid rgba(255, 255, 255, 0.08);

  color: #dbeafe;

  font-size: 12px;
  font-weight: 500;

  z-index: 950;

  opacity: 1;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;

  pointer-events: none;

  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.35);
}

.rotate-hint.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-8px);
}

.rotate-icon {
  font-size: 18px;
  line-height: 1;

  animation: rotateHintPulse 2.2s ease-in-out infinite;
}

@keyframes rotateHintPulse {
  0% {
    transform: rotate(0deg) scale(1);
    opacity: 0.8;
  }

  25% {
    transform: rotate(-12deg) scale(1.08);
    opacity: 1;
  }

  50% {
    transform: rotate(12deg) scale(1.08);
    opacity: 1;
  }

  100% {
    transform: rotate(0deg) scale(1);
    opacity: 0.8;
  }
}

/* desktop */
@media (min-width: 769px) {
  .rotate-hint {
    display: none;
  }
}

.zoom-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;

  margin-bottom: 12px;
}

.rotate-btn {
  user-select: none;
  width: 42px;
  height: 42px;

  border: none;
  border-radius: 12px;

  background: rgba(15, 23, 42, 0.75);
  color: #dbeafe;

  font-size: 20px;
  cursor: pointer;

  backdrop-filter: blur(10px);

  border: 1px solid rgba(255, 255, 255, 0.08);

  transition:
    transform 0.2s ease,
    background 0.2s ease;
}

.rotate-btn:hover {
  background: #1e293b;
  transform: scale(1.05);
}

.rotate-btn:active {
  transform: scale(0.94);
}

@media (max-width: 768px) {
  .zoom-toolbar {
    display: none;
  }
}

.image-rotator {
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: zoom-in;
  user-select: none;

  transform-origin: center center;

  will-change: transform;
}

@media (pointer: fine) {
  .image-rotator {
    transition: transform 0.25s ease;
  }
}

/* Контейнер иконок-подсказок */
.hint-icons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.hint-svg {
  display: block;
}

/* Анимация мигания для левой кнопки мыши */
.blink-left-btn {
  animation: blink-mouse-btn 1.8s ease-in-out infinite;
}

/* Анимация мигания для колёсика мыши */
.blink-wheel {
  animation: blink-wheel 2s ease-in-out infinite;
}

/* Анимация мигания для пробела */
.blink-space {
  animation: blink-key 2s ease-in-out infinite;
}

/* Анимация мигания для стрелок */
.blink-arrow {
  animation: blink-key 2s ease-in-out infinite;
}

/* Задержки анимаций (синхронно для мыши, раздельно для клавиатуры) */
.blink-left-btn,
.blink-wheel {
  animation-delay: 0s;
}

.blink-space {
  animation-delay: 0s;
}

.blink-arrow {
  animation-delay: 0.8s;
}

/* Кейфреймы */
@keyframes blink-mouse-btn {

  0%,
  100% {
    opacity: 0.3;
  }

  50% {
    opacity: 0.9;
  }
}

@keyframes blink-wheel {

  0%,
  100% {
    opacity: 0.3;
  }

  50% {
    opacity: 0.9;
  }
}

@keyframes blink-key {

  0%,
  100% {
    opacity: 0.3;
  }

  50% {
    opacity: 0.9;
  }
}