/* =========================================
   기본 초기화
   ========================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0; 
    padding: 0; 
}
html { 
    -webkit-text-size-adjust: 100%; 
    overflow-x: hidden; 
}
body {
    font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
    line-height: 1.6;
    color: #333;
}
img { max-width: 100%; height: auto; }
a { color: #F5B041; text-decoration: none; }

/* =========================================
   ★ 전체 컨테이너 (1200px 고정) ★
   ========================================= */
#wrap {
    width: 1200px;
    max-width: 100%;
    margin: 0 auto;
    background-color: #fff;
    border: 0 solid #eee;
    /* ★ 중요: wrap도 높이를 유동적으로 */
    height: auto !important;
}

/* =========================================
   헤더 및 네비게이션
   ========================================= */
#header {
    width: 100%;
    position: relative;
    border-bottom: 2px solid #FFFFFF;
    padding: 10px 10px 0 0;
}
#gnb {
    margin-bottom: 1px;
    padding: 1px 3px;  
    background: #ffffff;
    border-bottom: 1px solid #ffffff; /*#f9e79f;  #fffbea*/
}
#gnb a {
    display: inline-block;
    margin-right: 10px;
    font-weight: bold;
    color: #999999; /*#d68910; */
}

/* =========================================
   ★ 전체 콘텐츠 영역 (Flex) ★
   ========================================= */
#content-wrap {
    display: flex;
    justify-content: space-between;
    width: 1200px;
    margin: 0 auto 10px auto;
    align-items: flex-start; /* 위에서부터 정렬 */
}

/* ★ 좌측 컬럼 (메인 + 하단입력 영역) ★ */
.left-column {
    width: 900px; /* 우측 사이드바 290px 제외한 나머지 */
    display: flex;
    flex-direction: column; /* 위아래로 쌓기 */
    gap: 10px; /* 메인 영역과 하단 영역 사이 간격 10px */
}

/* =========================================
   ★ 공통 레이아웃 (상단/중간/하단) ★
   ========================================= */
.main-row, .bottom-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
    margin-bottom: 10px;
}

/* ★ 1단(전체 폭) 모드 ★ */
.main-row.full-width {
    display: flex; /* ★ block 대신 flex 유지 (테이블 깨짐 방지) */
}
.main-row.full-width .box-left {
    width: 100% !important; /* ★ 좌측이 전체 폭을 차지 */
}
.main-row.full-width .box-right {
    display: none !important; /* 우측 숨김 */
}

/* ★ 2단 모드 (기본값, 445px씩) ★ */
.box-left { width: 445px; }
.box-right { width: 445px; }

/* ★ "비움" 처리 (좌측 445px 유지, 우측 빈 공간 유지) ★ */
.main-row.keep-blank .box-left { width: 445px; }
.main-row.keep-blank .box-right { display: block; width: 445px; } 

/* =========================================
   ★ 중간/하단 영역 (bottom-row) ★
   ========================================= */
.bottom-row {
    display: grid;
    gap: 10px;
    width: 100%;
    margin-bottom: 10px;
}

/* mode에 따른 칸 수 조절 */
.bottom-row.mode-1 { grid-template-columns: 1fr; }
.bottom-row.mode-2 { grid-template-columns: 1fr 1fr; }

/* ★ 중요: 자식이 하나만 있으면 100% 차지하도록 강제 ★ */
.bottom-row > .bottom-box:only-child {
    grid-column: 1 / -1;
}

.bottom-box {
    background-color: #f9f9f9;
    min-height: 50px;
    overflow: hidden; 
}
/* mode 분기 (기존과 동일) */
#bottom-area.bottom-mode-10 { grid-template-columns: 1fr; }
#bottom-area.bottom-mode-10 .box-top-2 { display: none; }
#bottom-area.bottom-mode-22 { grid-template-columns: 1fr 1fr; }
#bottom-area.bottom-mode-12 { grid-template-columns: 2fr 1fr; }
#bottom-area.bottom-mode-21 { grid-template-columns: 1fr 2fr; }
/* ★ 추가: mode=10 이지만 하단은 2단으로 강제하는 클래스 ★ */
#bottom-area.bottom-mode-10-2col {
    grid-template-columns: 1fr 1fr; /* 하단 2단 */
}
#bottom-area.bottom-mode-10-2col .box-top-2 {
    display: block; /* 숨김 해제 */
}
/* 우측 사이드바 */
#sidebar { 
    width: 290px; 
    height: auto !important; 
}

/* 푸터 */
#footer {
    height: 100px;
    border-top: 2px solid #dddddd; /*#F5B041; */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #666666; /*#F5B041; */
    clear: both; /* 푸터도 겹침 방지 */
}

/* =========================================
   모바일 및 반응형 (1023px 이하)
   ========================================= */
#mobile-menu-btn {
    display: none;
    position: absolute;
    right: 1px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 28px;
    background: none;
    border: none;
    cursor: pointer;
    color: #F5B041;
}

/* =========================================
   모바일 및 반응형 (1199px 이하)
   ========================================= */
@media screen and (max-width: 780px) {
    /* 1. 전체 화면 가로 스크롤 원천 차단 */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 2. 모든 컨테이너 100% 너비 강제 */
    #wrap, #content-wrap, .left-column, .main-row, .bottom-row, .box-left, .box-right, #sidebar, .bottom-box {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* 3. 전체 콘텐츠 영역 세로 정렬 */
    #content-wrap {
        display: flex !important;
        flex-direction: column !important;
        padding: 0 5px;
        gap: 15px; 
    }

    .left-column {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px;
    }

    /* 4. 상단/중간/하단 모든 행을 세로(1열)로 강제 */
    .main-row, .bottom-row {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 10px !important;
    }

    /* 5. "비움" 처리된 우측 박스 숨김 */
    .main-row.keep-blank .box-right {
        display: none !important;
    }

    /* 6. 개별 박스 100% 및 넘침 방지 */
    .box, .bottom-box {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* ★ 7. 폼(Form) 요소들이 화면 폭을 넘지 못하도록 강제 ★ */
    .box form, .bottom-box form {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .box input, .bottom-box input,
    .box select, .bottom-box select,
    .box textarea, .bottom-box textarea {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* ★ 8. 폼 내부의 테이블도 화면 폭에 맞춤 ★ */
    /* 
    .box form table, .bottom-box form table {
        width: 100% !important;
        table-layout: fixed !important;
        word-break: break-all !important;
    }
    */

    /* ★ 9. 폼 내부 테이블의 셀(cell)이 줄어들도록 설정 ★ */
    /*
    .box form table td, .bottom-box form table td {
        width: 100% !important;
        padding: 2px !important;
        font-size: 12px !important;
    }
    */

    /* 10. 만세력/원국 표 처리 */
  /*  .box table, .bottom-box table {
        width: 100% !important;
        max-width: 100% !important;
        table-layout: fixed !important;
        word-break: break-all !important;
        border-collapse: collapse !important;
    }

    .box table img, .bottom-box table img {
        max-width: 100% !important;
        height: auto !important;
    } */

    #sidebar {
        width: 100% !important;
    }
}
/* =========================================
   ★ 상단 메뉴(topnnew_menu) 레이아웃 강제 고정 ★
   ========================================= */
#gnb {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    border-bottom: 1px solid #ddd !important;
    
    /* ★ 중요: 메뉴 내부의 테이블이나 리스트가 layout.css의 초기화(*) 영향을 받지 않도록 복구 */
    line-height: normal !important;
}

#gnb table {
    border-collapse: separate !important; /* 테이블 간격 복구 */
    border-spacing: 2px !important;
}

#gnb td, #gnb th {
    padding: 2px 5px !important; /* 셀 내부 여백 복구 */
    vertical-align: middle !important;
}

#gnb a {
    display: inline-block !important;
    margin-right: 10px !important;
    font-weight: bold !important;
    color: #333 !important; 
    text-decoration: none !important;
}

#gnb img {
    vertical-align: middle !important; /* 아이콘 정렬 */
}
/* =========================================
   초소형 모바일 (767px 이하)
   ========================================= */
@media screen and (max-width: 730px) {
    #mobile-menu-btn { 
        display: block; 
    }
    
    #sidebar.mobile-hidden { 
        display: none; 
    }

    #content-wrap { padding: 0; }
    .box { padding: 2px; }
    .bottom-box { padding: 10px; }
}