* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overscroll-behavior: none; /* Запрещает "отскок" страницы на мобильных */
}

body {
    font-family: sans-serif;
    background: #f4f4f9;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Центр по вертикали */
    align-items: center;     /* Центр по горизонтали */
    min-height: 100vh;
    width: 100%;
    margin: 0;
}

.upload-bar {
    padding: 15px;
    background: #fff;
    text-align: center;
    border-bottom: 1px solid #ddd;
    z-index: 10;
}

/* 3. Гарантируем, что контейнер занимает всю ширину */
.main-container {
    display: none; /* Скрыто до загрузки */
    flex-direction: column; 
    width: 100%;
    min-height: 100vh;
}

/* 4. Ограничиваем область редактора, чтобы тени не вылезали */
.editor-section {
    flex: 0 0 60vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #333;
    overflow: hidden; /* КРИТИЧНО: чтобы тень crop-box не вылезала за пределы секции */
    position: relative;
    touch-action: none;
}




.editor-section {
    position: relative; /* Важно для позиционирования инструментов */
}

.editor-tools {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 10px;
    z-index: 20;
    align-items: center;
    justify-content: center;
}

.editor-tools button {
    padding: 8px 12px;
    font-size: 13px;
    background: #444;
    color: white;
    border: 1px solid #666;
}

/* Скрываем инструменты до активации режима обрезки */
.editor-tools.hidden-controls button:not(#btn-crop-mode),
.editor-tools.hidden-controls .slider-container {
    display: none;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 5px;
    color: white;
    font-size: 12px;
}

#angle-slider {
    width: 80px;
}






/* Секция превью (40% высоты на мобильном) */
.preview-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-top: 2px solid #ddd;
    padding: 20px;
}

/* Адаптация под ПК */
@media (min-width: 768px) {
    .main-container { flex-direction: row; }
    .editor-section { flex: 0 0 60%; }
    .preview-section { flex: 0 0 40%; border-top: none; border-left: 2px solid #ddd; }
}

#editor-wrapper {
    position: relative;
    line-height: 0;
    overflow: hidden;
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

#source-canvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

#crop-box {
    position: absolute;
    border: 1px solid #fff;
    box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.6);
    cursor: move;
    z-index: 5;
}

/* Тянучки */
.handle {
    position: absolute;
    width: 24px; height: 24px;
    background: #fff;
    border: 2px solid #007bff;
    border-radius: 50%;
    z-index: 10;
}
.nw { top: -12px; left: -12px; cursor: nw-resize; }
.ne { top: -12px; right: -12px; cursor: ne-resize; }
.sw { bottom: -12px; left: -12px; cursor: sw-resize; }
.se { bottom: -12px; right: -12px; cursor: se-resize; }

.handle-line { position: absolute; background: transparent; z-index: 9; }
.n { top: -15px; left: 0; right: 0; height: 30px; cursor: n-resize; }
.s { bottom: -15px; left: 0; right: 0; height: 30px; cursor: s-resize; }
.w { left: -15px; top: 0; bottom: 0; width: 30px; cursor: w-resize; }
.e { right: -15px; top: 0; bottom: 0; width: 30px; cursor: e-resize; }

#preview-canvas {
    max-width: 100%;
    max-height: 250px;
    border: 1px solid #333;
    margin-bottom: 15px;
}

.preview-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

button {
    padding: 15px 30px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
}



/* Скрываем рабочую область до загрузки */
.main-container {
    display: none;
}


/* 2. Центрируем drop-zone через абсолютное позиционирование */
.upload-area {
    position: fixed; /* Чтобы была точно по центру экрана */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    padding: 40px;
    border: 2px dashed #ccc;
    border-radius: 15px;
    text-align: center;
    background: #fff;
    cursor: pointer;
    z-index: 100;
}

.upload-area:hover, .upload-area.drag-over {
    border-color: #007bff;
    background: #f0f7ff;
}

.upload-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.upload-area p {
    color: #666;
    font-size: 16px;
}

.upload-area span {
    color: #007bff;
    font-weight: bold;
    text-decoration: underline;
}

/* Скрываем всё до загрузки, как просили */
.main-container { display: none; }
