@media (max-width: 991.98px) {
    .navbar .container {
        flex-wrap: wrap;
        padding: 8px 16px;
    }

    .navbar-brand {
        min-width: 0;
        max-width: calc(100% - 58px);
    }

    .navbar-brand img {
        width: 46px;
        height: 46px;
        flex: 0 0 46px;
        object-fit: contain;
    }

    .navbar-brand h5 {
        font-size: 15px;
    }

    .navbar-brand small {
        font-size: 11px;
    }

    .navbar-toggler {
        flex: 0 0 auto;
        padding: 8px 10px;
        border-radius: 12px;
    }

    .navbar-collapse {
        flex-basis: 100%;
        max-height: calc(100dvh - 76px);
        overflow-y: auto;
        padding: 8px 0 12px;
        border-top: 1px solid #eef2f7;
    }

    .navbar-nav {
        align-items: stretch;
        gap: 3px;
        padding-top: 4px;
    }

    .navbar-nav .nav-item {
        padding: 0 4px;
    }

    .navbar-nav .nav-link {
        margin: 0;
        padding: 10px 12px;
        border-radius: 10px;
        font-size: 15px;
    }

    .navbar-nav .nav-link:hover,
    .navbar-nav .nav-link:focus-visible {
        background: #f1f5fb;
    }

    .navbar .nav-link::after {
        display: none;
    }

    .navbar .nav-link.dropdown-toggle::after {
        position: static;
        display: inline-block;
        width: 0;
        height: 0;
        margin-left: 0.4em;
        vertical-align: 0.2em;
        content: "";
        background: transparent;
        border-top: 0.3em solid;
        border-right: 0.3em solid transparent;
        border-bottom: 0;
        border-left: 0.3em solid transparent;
        transition: none;
    }

    .navbar-nav .dropdown-menu {
        position: static;
        width: 100%;
        margin: 0;
        padding: 4px 0 8px 10px;
        border: 0;
        border-radius: 10px;
        background: #f8fafc;
        box-shadow: none;
        animation: none;
    }

    .navbar-nav .dropdown-item {
        padding: 9px 14px;
        white-space: normal;
    }

    .navbar-nav .dropdown-item:hover,
    .navbar-nav .dropdown-item:focus {
        padding-left: 18px;
    }

    .navbar-nav .btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        margin-top: 8px;
        text-align: left;
    }

    .section-wave svg {
        width: 100%;
        height: auto;
    }

    .hero .carousel,
    .hero .carousel-inner,
    .hero .carousel-item {
        min-height: min(760px, calc(100svh - 70px));
    }

    .hero-image {
        height: min(760px, calc(100svh - 70px));
        min-height: 500px;
    }

    .carousel-caption {
        right: 10%;
        left: 10%;
        width: 80%;
    }

    .carousel-caption h1 {
        font-size: clamp(38px, 7vw, 60px);
        line-height: 1.12;
    }

    .carousel-caption p {
        max-width: 620px;
        font-size: clamp(16px, 2.4vw, 20px);
        line-height: 1.6;
    }

    .hero-stat {
        gap: clamp(20px, 6vw, 56px);
        margin-top: 32px !important;
    }

    .hero-stat h2 {
        font-size: clamp(26px, 5vw, 36px);
    }

    .hero-stat span {
        font-size: 13px;
    }
}

@media (max-width: 575.98px) {
    section {
        padding: 52px 0;
    }

    .navbar .container {
        padding-right: 12px;
        padding-left: 12px;
    }

    .navbar-brand img {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
    }

    .navbar-brand h5 {
        font-size: 13px;
    }

    .navbar-brand small {
        font-size: 10px;
    }

    .navbar-toggler {
        padding: 7px 9px;
    }

    .hero .carousel,
    .hero .carousel-inner,
    .hero .carousel-item {
        min-height: max(590px, calc(100svh - 64px));
    }

    .hero-image {
        height: max(590px, calc(100svh - 64px));
        min-height: 590px;
    }

    .carousel-caption {
        right: 9%;
        left: 9%;
        width: 82%;
    }

    .carousel-caption .badge {
        max-width: 100%;
        white-space: normal;
        font-size: 11px;
    }

    .carousel-caption h1 {
        margin: 10px 0 !important;
        font-size: clamp(34px, 10vw, 48px);
        line-height: 1.12;
    }

    .carousel-caption p {
        font-size: 15px;
        line-height: 1.55;
    }

    .carousel-caption .btn {
        width: min(100%, 240px);
        margin: 8px 0 0 !important;
        padding: 12px 18px;
        font-size: 15px;
    }

    .hero-stat {
        gap: 12px;
        margin-top: 28px !important;
    }

    .hero-stat div {
        min-width: 0;
    }

    .hero-stat h2 {
        margin-bottom: 3px;
        font-size: 25px;
    }

    .hero-stat span {
        font-size: 10px;
        line-height: 1.3;
    }

    .carousel-control-prev,
    .carousel-control-next {
        width: 9%;
    }

    .welcome .row {
        row-gap: 28px;
    }

    .welcome img {
        display: block;
        width: 100%;
        max-height: 340px;
        object-fit: cover;
    }

    .welcome h2 {
        font-size: 25px;
    }

    .welcome p {
        font-size: 15px;
        line-height: 1.75;
    }

    .news-card,
    .achievement-card {
        height: auto;
    }

    .news-image,
    .achievement-image {
        height: 205px;
    }

    .ekskul-card {
        min-height: 170px;
    }

    .gallery-viewport {
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-snap-type: x mandatory;
        scrollbar-width: thin;
        scrollbar-color: #0d6efd #e8eef6;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch;
    }

    .gallery-track {
        width: max-content;
        gap: 12px;
        padding: 0 12px;
        animation: none;
    }

    .gallery-track:hover,
    .gallery-track:focus-within {
        animation-play-state: running;
    }

    .gallery-slide {
        flex-basis: min(82vw, 330px);
        max-width: none;
        scroll-snap-align: center;
    }

    .gallery-item {
        height: 210px;
        border-radius: 14px;
    }

    .video .ratio,
    .maps .ratio {
        border-radius: 14px;
    }

    .footer {
        padding-top: 40px !important;
    }

    .footer .d-flex {
        gap: 22px !important;
        font-size: 21px;
    }

    .home-back-to-top {
        right: 16px;
        bottom: 16px;
    }
}

.home-back-to-top {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1020;
    display: inline-flex;
    width: 46px;
    height: 46px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: #0d6efd;
    color: #fff;
    box-shadow: 0 8px 24px rgba(13, 110, 253, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.home-back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.home-back-to-top:hover,
.home-back-to-top:focus-visible {
    background: #084298;
    color: #fff;
}

.home-back-to-top:focus-visible {
    outline: 3px solid #93c5fd;
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .home-back-to-top {
        transition: none;
    }
}
