.ai-skip-link {
    position: fixed;
    top: 8px;
    left: 12px;
    z-index: 11000;
    transform: translateY(calc(-100% - 12px));
    padding: 10px 16px;
    background: #fff;
    color: #174e74;
    border: 2px solid currentColor;
}
.ai-skip-link:focus { transform: none; }
#ai-main-content { scroll-margin-top: 72px; }
.portlet-title .caption h1.ai-page-heading {
    display: inline;
    margin: 0;
    font-family: inherit;
    font-size: 20px;
    font-weight: 650;
    line-height: 1.35;
    color: #23445b;
}
.ai-progress-title { font-size: 22px; margin: 18px 0; }

/* ---------------------------------------------------------------------------
   모달 크기와 스크롤
   ---------------------------------------------------------------------------
   AI 화면의 모달은 내용이 얼마나 길지 미리 알 수 없습니다. 템플릿 목록은 고른
   유형에 따라 경고가 붙어 늘어나고, 검증은 단계가 열두 개까지 갑니다. 그대로
   두면 모달이 화면 밖으로 자라서 아래쪽 단추(취소·붙이기)가 안 보입니다.

   그래서 두 가지를 정합니다.

     높이  화면 위아래에 여백을 남기고 그 이상 안 커집니다.
           넘치는 만큼은 **모달 안에서** 스크롤합니다 - 페이지가 아니라.
     너비  기본 780, 큰 것(modal-lg)은 1140 까지. 표가 들어가는 모달이 많아
           부트스트랩 기본(600 / 900)으로는 열이 눌립니다.

   왜 modal-body 만 스크롤하나
   ---------------------------
   머리글(무엇을 고르는 창인지)과 발치(단추)는 늘 보여야 합니다. 모달 전체를
   스크롤하면 긴 목록에서 단추를 찾으려고 끝까지 내려야 합니다.

   이 파일은 AI 화면에서만 읽습니다. 다른 관리 화면의 모달은 그대로입니다.
   --------------------------------------------------------------------------- */

/* 밝은 AI 패널에서 안내·상태 텍스트가 공유하는 읽기 색상입니다. */
:root {
    --ai-text-muted: #526579;
    --ai-text-danger: #a52b35;
    --ai-text-success: #196c47;
    --ai-text-warning: #87500d;
    --ai-text-link: #21618c;
    --ai-text-accent: #24727a;
}

/* AI 전용 공통 크기: 제목 16px, 본문·입력·설명 14px. 수치 배지는 개별 규칙을 유지합니다. */
.page-content,
.modal-body { font-size: 14px; line-height: 1.7; }
.page-content .form-control,
.modal-body .form-control,
.page-content .btn,
.modal .btn,
.page-content small,
.modal small,
.page-content .small,
.modal .small,
.page-content .help-block,
.modal .help-block,
.page-content code,
.modal code,
.ai-shape-pop code { font-size: 14px; }
.page-content .portlet-title .caption,
.modal-title { font-size: 16px; }
.page-content .portlet > .portlet-title > .caption > .caption-helper {
    color: var(--ai-text-muted, #526579);
    font-size: 14px;
}

/* 머리글·발치는 고정, 가운데만 늘었다 줄었다 합니다. */
.modal-content {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;

    /* 위아래 여백 24px 씩. 아래 .modal-dialog 의 margin 과 같은 값입니다 -
       한쪽만 고치면 모달이 화면을 넘거나 여백이 두 배가 됩니다. */
    max-height: calc(100vh - 48px);
}

.modal-header,
.modal-footer {
    -webkit-box-flex: 0;
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
}

/* 모델명·버전은 좁은 화면에서도 생략하지 않고 줄을 바꿉니다. */
#ai-new-title {
    padding-right: 24px;
    overflow-wrap: anywhere;
}

.modal-body {
    -webkit-box-flex: 1;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* 부트스트랩은 .modal 에 세로 스크롤을 둡니다. 내용이 이미 화면 안으로
   묶였으므로 바깥 스크롤은 쓸 일이 없습니다 - 두 개가 같이 생기면 어느 것을
   굴려야 하는지 헷갈립니다. */
body.modal-open,
.modal-open .modal {
    /* The shared theme forces overflow-y:auto!important on both layers. */
    overflow-y: hidden !important;
}

.modal-dialog {
    margin: 24px auto;
}

@media (min-width: 768px) {
    .modal-dialog { width: 780px; }
    .modal-lg     { width: 1140px; }
}

/* 화면이 1140 + 여백보다 좁으면 너비를 화면에 맞춥니다. 고정값으로 두면
   가로 스크롤이 생기고, 표가 든 모달에서는 오른쪽 열이 잘립니다. */
@media (min-width: 768px) and (max-width: 1187px) {
    .modal-lg {
        width: auto;
        margin-left: 24px;
        margin-right: 24px;
    }
}

@media (min-width: 768px) and (max-width: 827px) {
    .modal-dialog {
        width: auto;
        margin-left: 24px;
        margin-right: 24px;
    }
}

@media (max-width: 767px) {
    .modal-dialog,
    .modal-lg {
        width: auto;
        margin: 12px;
    }
    .modal-content {
        max-height: calc(100vh - 24px);
    }
}

/* 모달 안의 표는 넘치면 가로로 굴립니다. 열을 줄여 글자를 겹치게 하는 것보다
   낫습니다 - 템플릿 목록처럼 열이 많은 표가 있습니다. */
.modal-body > table,
.modal-body .ai-modal-scroll-x {
    display: block;
    overflow-x: auto;
    max-width: 100%;
}

/* 모달 안의 코드 상자는 자기 높이를 따로 잡고 있었습니다. 이제 모달이
   높이를 책임지므로 상자는 제 내용만큼만 차지하면 됩니다. 다만 아주 긴
   역추적은 그대로 두면 모달 하나를 통째로 먹어서 상한만 남깁니다. */
.modal-body pre.ai-code {
    max-height: 40vh;
    overflow: auto;
}

/* 자산 이력은 부모 창을 교체하지 않는 별도 읽기 창입니다. 전체 값은 줄바꿈으로 유지합니다. */
.ai-asset-history-modal .modal-title { padding-right: 24px; overflow-wrap: anywhere; }
.ai-history-table { width: 100%; min-width: 640px; table-layout: fixed; }
.ai-history-table th:nth-child(1) { width: 17%; }
.ai-history-table th:nth-child(2) { width: 10%; }
.ai-history-table th:nth-child(3) { width: 19%; }
.ai-history-table th:nth-child(4) { width: 14%; }
.ai-history-table th:nth-child(5) { width: 40%; }
.ai-history-table td { overflow-wrap: anywhere; }
.ai-history-table .ai-history-detail { white-space: pre-wrap; }
.ai-asset-history-modal .ai-history-pages .btn { margin: 4px 4px 0 0; }

/* 장치가 적으면 표를 접고, 많은 행은 표 안에서 전체 값을 스크롤합니다. */
.ai-asset-device-picker .fixed-table-body {
    max-height: 340px;
}

/* AI 창의 닫기는 이미지 아이콘 대신 읽을 수 있는 크기로 표시합니다. */
.modal-header button.close {
    width: 32px;
    height: 32px;
    margin: -6px 0 -6px 12px;
    background: none;
    background-image: none !important;
    color: var(--ai-text-muted, #526579);
    font-size: 28px;
    font-weight: normal;
    line-height: 32px;
    text-shadow: none;
    text-indent: 0;
    opacity: 1;
}

.modal-header button.close:empty::before { content: "×"; }
.modal-header .modal-title { overflow-wrap: anywhere; }
.modal-header button.close:focus {
    outline: 2px solid #337ab7;
    outline-offset: 2px;
}

/* 모든 AI 상세 창에서 펼침 동작과 키보드 초점을 알아볼 수 있게 합니다. */
.page-content details > summary,
.modal-body details > summary {
    display: list-item;
    list-style: disclosure-closed inside;
    padding: 10px 12px;
    margin: 6px 0;
    background: #f5f8fb;
    border: 1px solid #d7e1eb;
    border-radius: 4px;
    color: #254b6b;
    cursor: pointer;
    line-height: 1.65;
    overflow-wrap: anywhere;
}
.page-content details[open] > summary,
.modal-body details[open] > summary { list-style-type: disclosure-open; background: #eaf2f9; }
.page-content details > summary:focus-visible,
.modal-body details > summary:focus-visible { outline: 2px solid #21618c; outline-offset: 2px; }
.page-content .btn,
.modal .btn { min-height: 36px; white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
.page-content .form-control,
.modal .form-control { min-height: 38px; }
.modal-body p, .modal-title { overflow-wrap: anywhere; }
@media (max-width: 767px) {
    .page-content .btn, .modal .btn { min-height: 44px; }
    .modal-header button.close { width: 44px; height: 44px; line-height: 44px; margin-top: -10px; }
    .modal-footer { display: flex; flex-wrap: wrap; gap: 8px; }
    .modal-footer .btn + .btn { margin-left: 0; }
}

/* Image source records keep the original pixels and complete encoded value together. */
.ai-asset-source-image {
    display: block;
    width: 320px;
    max-width: none;
    height: auto;
    margin: 16px 0;
    image-rendering: pixelated;
}
.ai-asset-source-base64 {
    width: 320px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-all;
}
.ai-asset-source-guide { padding: 12px; background: #edf5fb; border-left: 3px solid #337ab7; }

@media (max-width: 767px) {
    .ai-asset-image-table, .ai-asset-image-table tbody,
    .ai-asset-image-table tr, .ai-asset-image-table td {
        display: block;
        width: 100%;
        min-width: 0 !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }
    .ai-asset-image-table thead { display: none; }
    .ai-asset-image-table tr { margin-bottom: 16px; padding: 12px; border: 1px solid #d7e1eb; }
    .ai-asset-image-table td[data-label]::before { content: attr(data-label); display: block; font-weight: 600; color: #526579; }
    .ai-asset-image-table .ai-asset-source-image,
    .ai-asset-image-table .ai-asset-source-base64 { width: 100%; max-width: 100%; }
}
