:root {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
}

button,
input,
select,
textarea,
a {
    touch-action: manipulation;
}

/* 로그인, 회원가입, 내 정보 */
body.auth-page {
    width: auto !important;
    padding: 0 18px 28px;
}

body.auth-page input,
body.auth-page select,
body.auth-page button {
    max-width: 100%;
    font: inherit;
}

body.auth-page input,
body.auth-page select {
    min-width: 0;
}

@media (max-width: 900px) {
    /* 검색 결과 화면 */
    body.main-page {
        display: block;
        min-width: 0;
        min-height: 100dvh;
        overflow-x: hidden;
    }

    body.main-page .topbar {
        position: sticky;
        top: 0;
        width: 100%;
        height: auto;
        padding: 10px 12px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        z-index: 100;
    }

    body.main-page .topbar-left,
    body.main-page .topbar-right,
    body.main-page .search-area,
    body.main-page .search-form {
        width: 100%;
        max-width: none;
    }

    body.main-page .topbar-title,
    body.main-page .topbar-title .home-btn {
        display: block;
        width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.main-page .topbar-title .home-btn {
        padding: 8px 10px;
        text-align: center;
    }

    body.main-page .topbar-center {
        display: none;
    }

    body.main-page .search-area {
        margin: 0;
        transform: none;
    }

    body.main-page .search-box {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: 7px;
        width: 100%;
    }

    body.main-page .search-area input[type="text"] {
        width: 100%;
        min-width: 0;
        height: 44px;
        font-size: 16px;
    }

    body.main-page .search-area button,
    body.main-page .search-box > .home-btn {
        min-height: 44px;
        padding: 10px 12px;
        white-space: nowrap;
    }

    body.main-page .layout {
        position: relative;
        inset: auto;
        display: block;
        min-height: 0;
    }

    body.main-page .tabbar {
        width: 100%;
        height: 48px;
        padding: 0 8px;
        align-items: stretch;
        gap: 2px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
    }

    body.main-page .tab-btn {
        flex: 0 0 auto;
        min-height: 44px;
        padding: 10px 11px 8px;
        white-space: nowrap;
    }

    body.main-page .tabpanes,
    body.main-page .tab-pane {
        height: auto;
        min-height: 0;
    }

    body.main-page .tab-pane.active {
        display: flex;
        flex-direction: column;
    }

    body.main-page .sidebar {
        width: 100% !important;
        height: min(38dvh, 360px);
        flex: 0 0 auto;
        padding: 12px;
        border-right: 0;
        border-bottom: 2px solid #cbd5e1;
        overscroll-behavior: contain;
    }

    body.main-page .splitter {
        display: none;
    }

    body.main-page .content {
        width: 100%;
        min-width: 0;
        min-height: 48dvh;
        padding: 12px;
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
    }

    body.main-page .content .ref-table {
        min-width: 900px;
    }

    body.main-page .entry,
    body.main-page .nae-entry,
    body.main-page .group-header {
        min-height: 44px;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    body.main-page .table-title {
        margin-top: 16px;
    }

    body.main-page .script-box {
        min-width: 100%;
        padding-left: 16px;
        border-left-width: 8px;
        overflow-wrap: anywhere;
    }

    /* 포털 첫 화면 */
    body.portal-page .topbar {
        margin-top: 10px;
        padding: 0 12px;
    }

    body.portal-page .auth-links {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 6px;
    }

    body.portal-page .wrap {
        margin-top: 12px;
        padding: 0 12px;
    }

    body.portal-page .hero {
        padding: 18px 16px;
        border-radius: 16px;
    }

    body.portal-page .intro-title {
        font-size: clamp(24px, 7vw, 32px);
        line-height: 1.25;
    }

    body.portal-page .intro-subtitle {
        font-size: 15px;
    }

    body.portal-page .search-area {
        align-items: stretch;
    }

    body.portal-page .search-area input[type="text"],
    body.portal-page .btn-search {
        min-height: 46px;
    }

    body.portal-page .sector-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body.portal-page .sector-item,
    body.portal-page .ds-card {
        min-height: 48px;
    }

    body.portal-page .left,
    body.portal-page .right {
        padding: 12px;
        border-radius: 14px;
    }

    body.portal-page .join-section {
        padding: 14px;
    }

    /* 상세 팝업 */
    body.popup-page .header {
        gap: 8px;
        padding: 10px 12px;
        flex-wrap: wrap;
    }

    body.popup-page .search-bar {
        display: grid;
        grid-template-columns: 1fr auto;
        padding: 10px;
    }

    body.popup-page .search-bar select {
        grid-column: 1 / -1;
    }

    body.popup-page .search-bar input,
    body.popup-page .search-bar select,
    body.popup-page .search-bar button,
    body.popup-page .back-btn {
        min-width: 0;
        min-height: 44px;
        font-size: 16px;
    }

    body.popup-page .table-content {
        padding: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.popup-page .ref-table {
        min-width: 900px;
    }

    body.popup-page .script-box {
        padding-left: 16px;
        border-left-width: 8px;
    }
}

@media (max-width: 560px) {
    body.auth-page {
        margin: 20px auto !important;
        padding-inline: 14px;
    }

    body.auth-page h2 {
        margin-top: 0;
    }

    body.auth-page input,
    body.auth-page select,
    body.auth-page button {
        min-height: 44px;
    }

    body.main-page .search-box {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    body.main-page .search-box > .home-btn {
        grid-column: 1 / -1;
        text-align: center;
    }

    body.main-page .sidebar {
        height: 34dvh;
    }

    body.portal-page .search-area {
        flex-direction: column;
    }

    body.portal-page .btn-search {
        width: 100%;
    }

    body.portal-page .sector-list {
        grid-template-columns: 1fr;
    }

    body.portal-page .ds-top {
        flex-wrap: wrap;
    }

    body.popup-page .search-bar {
        grid-template-columns: 1fr;
    }

    body.popup-page .search-bar select {
        grid-column: auto;
    }

    body.popup-page .apply-btn {
        width: calc(100% - 24px);
        min-height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
