body, html {
    height: 100%;
    margin: 0;
    /* Добавлены системные шрифты для более нативного вида на iOS и Android */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, Calibri, sans-serif;
}

.bg {
    background-image: url('/images/background.jpg?v=03052026');
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    background-color: #f0f0f0;
    /* Современная высота viewport, исключающая скачки при скролле */
    min-height: 100vh;
    min-height: 100dvh;
    /* Гибкое центрирование вместо абсолютного */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    box-sizing: border-box;
    position: relative;
}

.content {
    color: white;
    background-color: rgba(0,0,0,0.5);
    padding: 25px;
    border-radius: 15px;
    width: 100%;
    max-width: 400px;
    min-width: 280px;

    /* Резервируем высоту, но разрешаем сжиматься и скроллиться на мелких экранах (когда открыта клавиатура) */
    height: 580px;
    max-height: 100%;
    overflow-y: auto;

    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* Заголовок по центру */
.content h1 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 20px;
}

/* Кнопки: контрастные и скругленные */
.content button {
    display: block;
    width: 70%;
    max-width: 220px;
    margin: 0 auto;
    padding: 10px;
    border-radius: 25px;
    border: 1px solid rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.25);
    color: white;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.content button:hover:not(:disabled) {
    background: rgba(255,255,255,0.4);
}

.content button:disabled {
    background: rgba(100, 100, 100, 0.2);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.4);
    cursor: not-allowed;
}

#showFileInputButton { margin-bottom: 25px; }
#runButton { margin-top: 20px; }

/* Сетка параметров (текст слева, поля справа) */
.row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 12px;
}

/* Защита от длинных имен GPX-файлов: обрезка многоточием */
#fileName {
    flex: 1;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Поля ввода: цифры слева */
.content input[type="number"] {
    width: 85px;
    text-align: left;
    padding: 5px 10px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.5);
    color: white;
    border-radius: 6px;
    outline: none; /* Переопределено выше через :focus */
}

#protectedContent {
    display: none;
}

#protectedContent[style] {
    display: flex !important;
}

.loader {
    order: 990; /* Будет выше почты, но ниже кнопок */
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid #ffffff;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin: 20px auto 5px;
}

.status {
    order: 991; /* Сразу под лоадером */
    color: white;
    font-size: 14px;
    text-align: center;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.mail-footer {
    order: 999; /* Гарантирует, что почта будет последней в Flex-контейнере */
    margin-top: auto;
    padding-top: 20px;
    text-align: center;
}

.mail-link {
    unicode-bidi: bidi-override;
    direction: rtl;
    color: #57a3f5;
    text-decoration: none;
    font-size: 13px;
}

/* =========================================================
   ЛАНДШАФТНЫЙ РЕЖИМ (Нативная заглушка)
   ========================================================= */
@media screen and (orientation: landscape) and (max-width: 950px) {
    /* Скрываем всё содержимое страницы */
    #protectedContent,
    #protectedContent[style] {
        display: none !important;
    }

    /* Превращаем body во flex-контейнер для заглушки */
    body {
        background: #121212 !important;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100dvh;
        margin: 0;
    }

    /* Анимированная иконка смартфона на чистом CSS */
    body::before {
        content: "";
        display: block;
        width: 36px;
        height: 64px;
        border: 3px solid #ffffff;
        border-radius: 6px;
        margin-bottom: 24px;
        position: relative;
        /* Имитация рамок экрана внутри "смартфона" */
        box-shadow: inset 0 6px 0 0 rgba(255,255,255,0.2), inset 0 -6px 0 0 rgba(255,255,255,0.2);
        -webkit-animation: rotatePhone 2s ease-in-out infinite alternate;
        animation: rotatePhone 2s ease-in-out infinite alternate;
    }

    /* Текст с инструкцией */
    body::after {
        content: "Please rotate your device\Ato portrait mode";
        white-space: pre-wrap; /* \A работает как перенос строки (<br>) */
        color: #ececec;
        font-size: 1.15rem;
        text-align: center;
        line-height: 1.4;
        padding: 0 20px;
        z-index: 999999;
    }

    @-webkit-keyframes rotatePhone {
        0%, 15% { -webkit-transform: rotate(-90deg); }
        85%, 100% { -webkit-transform: rotate(0deg); }
    }

    /* Анимация поворота устройства */
    @keyframes rotatePhone {
        0%, 15% { transform: rotate(-90deg); }
        85%, 100% { transform: rotate(0deg); }
    }
}
