/* Стили кнопки Loop в стиле модальных кнопок */
.block-loop-btn {
    position: absolute;
    right: 10px;
    bottom: 10px; /* перенос в нижний правый угол по умолчанию */
    background: transparent !important;
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    backdrop-filter: blur(5px) !important;
    -webkit-backdrop-filter: blur(5px) !important;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px rgba(100, 200, 255, 0.8), 
                 0 0 20px rgba(100, 200, 255, 0.6), 
                 0 0 30px rgba(100, 200, 255, 0.4);
    min-width: 60px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.block-loop-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
    text-shadow: 0 0 15px rgba(100, 200, 255, 1), 
                 0 0 25px rgba(100, 200, 255, 0.8), 
                 0 0 35px rgba(100, 200, 255, 0.6);
}

.block-loop-btn.active {
    right: 10px;
    bottom: 10px;
    min-width: 60px;
    height: 32px;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 50%, #a93226 100%) !important;
    color: white;
    border-color: #e74c3c !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    animation: pulse-button-fixed 1.5s infinite;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
    text-shadow: 0 0 10px rgba(255, 100, 100, 0.9), 
                 0 0 20px rgba(255, 100, 100, 0.7), 
                 0 0 30px rgba(255, 100, 100, 0.5);
}

@keyframes pulse-button-fixed {
    0% {
        box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
    }
    50% {
        box-shadow: 0 6px 20px rgba(231, 76, 60, 0.6);
    }
    100% {
        box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
    }
}

/* Стили границ петли в стиле модальных кнопок */
.loop-boundary-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #FF8C00 0%, #ff7b00 50%, #ff6b00 100%);
    border-radius: 2px;
    z-index: 1002;
    box-shadow: 0 2px 8px rgba(255, 140, 0, 0.4);
    cursor: ns-resize;
    transition: all 0.3s ease;
    opacity: 0.9;
    border: 1px solid rgba(255, 140, 0, 0.3);
}

.loop-boundary-line:hover {
    height: 6px;
    background: linear-gradient(90deg, #ff7b00 0%, #ff6b00 50%, #ff5500 100%);
    box-shadow: 0 4px 15px rgba(255, 140, 0, 0.6);
    opacity: 1;
    transform: scaleY(1.2);
    border-color: rgba(255, 123, 0, 0.5);
}

.loop-boundary-line.dragging {
    height: 6px;
    background: linear-gradient(90deg, #e74c3c 0%, #c0392b 50%, #a93226 100%);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.8);
    opacity: 1;
    z-index: 1010;
    border-color: rgba(231, 76, 60, 0.5);
}

.loop-boundary-line.disabled { pointer-events: none; opacity: 0.35; }

.loop-start-line {
    top: -3px;
}

.loop-end-line {
    bottom: -3px;
}

/* Ручка для перетаскивания линии */
.loop-boundary-line::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 16px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.4));
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.loop-boundary-line:hover::before {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

/* Увеличиваем hover зону для легкого захвата */
.loop-boundary-line::after {
    content: "";
    position: absolute;
    top: -8px;
    left: -4px;
    right: -4px;
    bottom: -8px;
    background: transparent;
    cursor: ns-resize;
}

/* Призрачная линия предпоказа */
.loop-boundary-ghost {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, rgba(255, 140, 0, 0.4), rgba(255, 123, 0, 0.4));
    border: 1px dashed rgba(255, 140, 0, 0.6);
    border-radius: 2px;
    z-index: 1005;
    opacity: 0.7;
    animation: ghostPulse 1s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes ghostPulse {
    0% { 
        opacity: 0.4; 
        transform: scaleY(0.8);
        box-shadow: 0 0 4px rgba(255, 140, 0, 0.3);
    }
    100% { 
        opacity: 0.8; 
        transform: scaleY(1.1);
        box-shadow: 0 0 8px rgba(255, 140, 0, 0.5);
    }
}

.loop-ghost-start {
    top: -2px;
}

.loop-ghost-end {
    bottom: -2px;
}

/* Затемнение строк вне диапазона */
.rehearsal-active-line.boundary-outside {
    opacity: 0.3;
    background: rgba(158, 158, 158, 0.05);
    filter: grayscale(0.5);
    transition: all 0.3s ease;
}

.rehearsal-active-line.boundary-outside:hover {
    opacity: 0.5;
    filter: grayscale(0.3);
}

/* Подсветка активного диапазона */
.rehearsal-active-line.boundary-inside {
    background: rgba(255, 140, 0, 0.08);
    transition: all 0.3s ease;
    border-left: 3px solid rgba(255, 140, 0, 0.4);
}

.rehearsal-active-line.boundary-start,
.rehearsal-active-line.boundary-end {
    background: rgba(255, 140, 0, 0.12);
    transition: all 0.3s ease;
    border-left: 4px solid #FF8C00;
    box-shadow: 0 2px 8px rgba(255, 140, 0, 0.2);
} 

.block-loop-plus-btn { display: none !important; }

/* Подсветка подключенного блока */
.rehearsal-active-block.loop-active { box-shadow: 0 0 0 3px rgba(255, 165, 0, 0.9) inset; }
.rehearsal-active-block.loop-linked,
.rehearsal-preview-block.loop-linked { box-shadow: 0 0 0 3px rgba(255, 165, 0, 0.7) inset; }

/* === Unified highlight for active and linked blocks (same intensity) === */
.rehearsal-active-block.loop-active,
.rehearsal-active-block.loop-linked,
.rehearsal-preview-block.loop-linked,
.rehearsal-preview-block.loop-active {
	box-shadow: 0 0 0 3px rgba(255, 165, 0, 0.95) inset, 0 0 18px rgba(255, 165, 0, 0.35) !important;
	border-color: transparent !important;
	background-color: transparent !important;
} 

/* Стек чипов под Stop */
.loop-chips-stack { display: flex; flex-direction: column; gap: 6px; }

/* Чип блока (квадратик с крестиком) */
.loop-chip {
	background: rgba(255,255,255,0.08);
	border: 1px solid rgba(255,255,255,0.35);
	color: rgba(255,165,0,0.95);
	width: 22px;
	height: 22px;
	border-radius: 6px;
	font-weight: 800;
	font-size: 12px;
	line-height: 20px;
	text-align: center;
	cursor: pointer;
	backdrop-filter: blur(5px);
	-webkit-backdrop-filter: blur(5px);
	box-shadow: 0 0 10px rgba(0,0,0,0.25) inset;
}
.loop-chip:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.55); }
.loop-chip:disabled { cursor: default; filter: saturate(0.4); } 

/* ====== Поезд вагончиков (V2) ====== */
.loop-train { margin-top: 0; position: relative; z-index: 9999; }
/* Поднимаем поезд над содержимым, чтобы верхняя линия лупа не перекрывалась */
.rehearsal-active-block .loop-train { top: -28px; z-index: 9999; left: 0; right: 0; }
/* Контейнер-пленка по ширине, скролл по X при большом числе блоков */
.loop-train { overflow-x: hidden; overflow-y: visible; white-space: nowrap; }
/* Скрываем стандартную полосу прокрутки (остается скролл мышью/тачем) */
.loop-train::-webkit-scrollbar { height: 0; }

/* Вагончик: размером с нижние кнопки (ориентир .transport-btn) */
.loop-wagon {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.45);
    color: rgba(255,255,255,0.95);
    height: 36px; /* близко к трансп. кнопкам по высоте */
    min-width: 48px; /* позволяем сжиматься при большом числе блоков */
    border-radius: 10px;
    padding: 6px 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 0 10px rgba(0,0,0,0.25) inset;
}
.loop-wagon:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.55); }
.loop-wagon.playing { border-color: rgba(100,200,255,0.9); box-shadow: 0 0 0 2px rgba(100,200,255,0.55); background: rgba(100,200,255,0.15); }

/* Вагон в составе луп-цепочки */
.loop-wagon.is-in-loop {
    background: rgba(255,140,0,0.22);
    border-color: rgba(255,140,0,0.7);
}

/* Тогглер в конце вагона */
.wagon-loop-toggle {
    margin-left: auto; width: 22px; height: 22px;
    border-radius: 6px; border: 1px solid rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.12); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; opacity: 0.9; transition: background .15s, border-color .15s, opacity .15s;
}
.wagon-loop-toggle::before { content: '+'; font-weight: 700; line-height: 1; }
.wagon-loop-toggle:hover { opacity: 1; background: rgba(255,255,255,0.18); }
.wagon-loop-toggle.is-on {
    background: rgba(220, 53, 69, 0.85); border-color: rgba(220,53,69,1);
}
.wagon-loop-toggle.is-on::before { content: '×'; font-weight: 800; }

/* Элегантная цветовая кодировка (приглушённые оттенки) */
.loop-wagon--verse {
    background: rgba(72, 187, 120, 0.14);
    border-color: rgba(72, 187, 120, 0.45);
}
.loop-wagon--verse:hover { background: rgba(72, 187, 120, 0.18); border-color: rgba(72, 187, 120, 0.6); }

.loop-wagon--chorus {
    background: rgba(231, 76, 60, 0.14);
    border-color: rgba(231, 76, 60, 0.45);
}
.loop-wagon--chorus:hover { background: rgba(231, 76, 60, 0.18); border-color: rgba(231, 76, 60, 0.6); }

.loop-wagon--bridge {
    background: rgba(155, 89, 182, 0.16);
    border-color: rgba(155, 89, 182, 0.45);
}
.loop-wagon--bridge:hover { background: rgba(155, 89, 182, 0.2); border-color: rgba(155, 89, 182, 0.6); }

/* Номер блока слева, компактный бейдж */
.loop-wagon__index {
    font-weight: 800;
    font-size: 13px;
    line-height: 1;
    background: rgba(255,255,255,0.22);
    border: 1px solid rgba(255,255,255,0.35);
    width: 22px;
    height: 22px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Первая строка с умным сокращением (одна строка + троеточие) */
.loop-wagon__title { font-weight: 500; font-size: 13px; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Кастомная подсказка вверх */
.loop-wagon[data-title] { position: relative; }
.loop-wagon[data-title]:hover::after {
    content: attr(data-title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-size: 12px;
    line-height: 1.1;
    white-space: nowrap;
    pointer-events: none;
    z-index: 100000;
}
.loop-wagon[data-title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: rgba(0,0,0,0.8);
}
.loop-wagon:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.55); }
.loop-wagon.playing { border-color: rgba(100,200,255,0.9); box-shadow: 0 0 0 2px rgba(100,200,255,0.55); background: rgba(100,200,255,0.15); } 