html,
body {
    min-height: 100%;
}

body {
    background: #f7f7f8;
    color: #202124;
}

.service-header {
    display: flex;
    align-items: center;
    gap: 18px;
}

.service-logo img {
    width: 200px;
    height: auto;
}

/* Autofocus остаётся, но стандартный синий glow Bootstrap 4 убран. */
.youtube-url:focus {
    border-color: #ced4da;
    box-shadow: none !important;
    outline: 0;
}



.history-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.history-title {
    font-weight: 600;
    color: #202124;
}

.download-stats {
    margin-left: auto;
    color: #6c757d;
    font-size: 14px;
    white-space: nowrap;
}

.download-stats strong {
    color: inherit;
}

/* ===== История обложек ===== */

.history {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    overflow: visible;
}

.history-item,
button.history-item {
    display: block;
    width: 100%;
    min-width: 0;
    aspect-ratio: 16 / 9;
    padding: 0;
    margin: 0;
    border: 0 !important;
    outline: 0;
    appearance: none;
    -webkit-appearance: none;
    overflow: hidden;
    border-radius: 8px;
    background: transparent;
    line-height: 0;
    cursor: pointer;
    box-shadow: none !important;
    transform: translateZ(0);
}

.history-item img {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
    object-fit: cover;
    object-position: center;
    border: 0;
    border-radius: inherit;
    transform: scale(1);
    transition: transform .20s ease;
    backface-visibility: hidden;
}

.history-item:hover img {
    transform: scale(1.055);
}

.history-item:focus,
.history-item:active {
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
}


/* ===== Результат ===== */

.result-card {
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
    transform-origin: top center;
}

/* Быстрое плавное "выезжание" блока загрузки после клика. */
.result-card.result-enter {
    animation: resultEnter .28s cubic-bezier(.2,.8,.2,1) both;
}

.thumb-stage {
    position: relative;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 14px;
    background: #eceff3;
    display: grid;
    place-items: center;
}

.result-image {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #111;

    /* До полной загрузки/декодирования изображение вообще невидимо. */
    visibility: hidden;
    opacity: 0;
    transform: scale(1.012);
    transition:
        opacity .38s ease,
        transform .42s cubic-bezier(.2,.8,.2,1);
    pointer-events: none;
}

.result-image.is-loaded {
    visibility: visible;
}

.thumb-stage.is-ready .result-image {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.loading-label {
    position: absolute;
    z-index: 2;
    top: calc(50% + 54px);
    left: 20px;
    right: 20px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
    transition: opacity .18s ease;
}

.wave-loader {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 7px;
    height: 54px;
    transition: opacity .18s ease;
}

.wave-loader span {
    width: 7px;
    height: 18px;
    border-radius: 999px;
    background: #6c757d;
    animation: wave 1s ease-in-out infinite;
}

.wave-loader span:nth-child(2) { animation-delay: .08s; }
.wave-loader span:nth-child(3) { animation-delay: .16s; }
.wave-loader span:nth-child(4) { animation-delay: .24s; }
.wave-loader span:nth-child(5) { animation-delay: .32s; }

.thumb-stage.is-ready .wave-loader,
.thumb-stage.is-ready .loading-label,
.thumb-stage.is-error .wave-loader,
.thumb-stage.is-error .loading-label {
    opacity: 0;
    pointer-events: none;
}

.result-actions {
    display: flex;
    gap: 10px;
}


/* ===== Анимации ===== */

@keyframes wave {
    0%, 100% {
        transform: scaleY(.75);
        opacity: .45;
    }

    50% {
        transform: scaleY(2.4);
        opacity: 1;
    }
}

@keyframes resultEnter {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(.992);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* ===== Адаптив ===== */

/* Только два режима истории:
   - 8 карточек в ряд на широком экране
   - 4 карточки в ряд на более узком экране
*/
@media (max-width: 1199.98px) {
    .history {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
    }
}

@media (hover: none) {
    .history-item:hover img {
        transform: scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .wave-loader span,
    .result-card.result-enter {
        animation: none;
    }

    .result-image,
    .history-item img {
        transition: none;
    }
}


@media (max-width: 575.98px) {
    .history-head {
        align-items: center;
        gap: 10px;
    }

    .history-title,
    .download-stats {
        font-size: 13px;
    }
}


/* ===== Подсказка рядом с кнопкой ===== */

.result-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
}

.quality-hint {
    flex: 1 1 320px;
    min-width: 0;
    font-size: 13px;
    line-height: 1.4;
}


/* ===== SEO-блок ===== */

.seo-section {
    padding: 24px 0 8px;
    color: #4f5459;
    line-height: 1.65;
}

.seo-section h2 {
    color: #202124;
}

.seo-section p {
    max-width: 900px;
}


/* ===== Footer ===== */

.site-footer {
    margin-top: 34px;
    padding: 20px 0 26px;
    border-top: 1px solid #e9ecef;
    color: #8a8f94;
    font-size: 13px;
}


/* На узком экране текст под кнопкой занимает всю строку. */
@media (max-width: 575.98px) {
    .result-actions {
        align-items: flex-start;
    }

    .quality-hint {
        flex-basis: 100%;
    }
}


/* Плавная смена muted-подсказки */
.quality-hint {
    opacity: 1;
    transform: translateY(0);
    transition:
        opacity .14s ease,
        transform .14s ease;
}

.quality-hint.is-changing {
    opacity: 0;
    transform: translateY(2px);
}


/* ===== Search form ===== */

.search-card {
    border-radius: 10px;
    box-shadow: none !important;
}

.search-clear-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-left: 11px;
    padding-right: 11px;
    border-color: #ced4da;
    background: #fff;
    box-shadow: none !important;
}

.search-clear-btn img {
    display: block;
    opacity: .45;
    transition: opacity .16s ease;
}

.search-clear-btn:hover img,
.search-clear-btn:focus img {
    opacity: 1;
}

.search-clear-btn:hover,
.search-clear-btn:focus {
    background: #fff;
    border-color: #ced4da;
    box-shadow: none !important;
}




/* ===== Form width + example ===== */
.search-form-wrap {
    width: 50%;
}

.search-example {
    color: #8a8f94;
    font-size: 13px;
}

.search-example-link {
    padding: 0;
    border: 0;
    background: transparent;
    color: #6c757d;
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.search-example-link:hover,
.search-example-link:focus {
    color: #202124;
    outline: 0;
}

@media (max-width: 767.98px) {
    .search-form-wrap {
        width: 100%;
    }
}


/* ===== Header responsive ===== */

.service-header {
    margin-bottom: 34px !important;
}

.service-title {
    font-size: 1.25rem;
    line-height: 1.3;
}

.service-title-mobile {
    display: none;
}

@media (max-width: 767.98px) {
    .service-header {
        flex-direction: column;
        align-items: center;
        text-align: center;

        gap: 10px;
        margin-bottom: 24px !important;
    }

    .service-logo {
        display: block;
        width: 100%;
        text-align: center;
    }

    .service-logo img {
        width: 180px;
        max-width: 80%;
        height: auto;
        margin: 0 auto;
    }

    .service-title {
        margin: 0;
        font-size: 1rem;
        line-height: 1.25;
        font-weight: 600;
    }

    .service-title-desktop {
        display: none;
    }

    .service-title-mobile {
        display: inline;
    }

    .service-header .text-muted {
        font-size: 14px;
    }
}


/* Обычный размер текста для примера под формой */
.search-example {
    font-size: 16px;
    line-height: 1.5;
}


/* Кнопка очистки поля — без рамки/обводки */
.search-clear-btn,
.search-clear-btn:hover,
.search-clear-btn:focus,
.search-clear-btn:active {
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
}

.search-clear-btn {
    background: transparent !important;
}




/* Стабильное положение крестика внутри самого input */
.search-input-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.search-input-wrap .youtube-url {
    width: 100%;
    padding-right: 42px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.search-clear-btn,
.search-clear-btn:hover,
.search-clear-btn:focus,
.search-clear-btn:active {
    position: absolute;
    z-index: 5;
    top: 50%;
    right: 10px;
    width: 22px;
    height: 22px;
    padding: 0;
    margin: 0;
    transform: translateY(-50%);
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer;
}

.search-clear-btn img {
    display: block;
    width: 18px;
    height: 18px;
    margin: 2px auto;
    opacity: .45;
    transition: opacity .16s ease;
}

.search-clear-btn:hover img,
.search-clear-btn:focus img {
    opacity: 1;
}