@layer t2.plugin {
/* Path: T2Editor/plugin/image/image.css */
/* Rationale: image 선택자는 플러그인 루트 아래로 제한하고 공개 본문 표현이 필요하면 css/content.css도 함께 수정한다. */

/* ===== 디자인 토큰 =====
   공식 플러그인 표면의 반경·깊이·동작 변수를 분리하고
   라이트·다크에서 같은 구조와 판단 원칙을 유지한다. */
:root {
  --t2-img-radius-lg: var(--t2-radius-modal, 4px);
  --t2-img-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t2-img-modal-shadow:
    0 1px 1px rgba(15, 23, 42, 0.03),
    0 8px 24px -8px rgba(15, 23, 42, 0.16),
    0 24px 64px -12px rgba(15, 35, 60, 0.22);
  --t2-img-modal-shadow-dark:
    0 0 0 1px rgba(255, 255, 255, 0.04),
    0 12px 32px -8px rgba(0, 0, 0, 0.55),
    0 32px 80px -16px rgba(0, 0, 0, 0.65);
}

@keyframes t2ImgSheetSlideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ===== 이미지 에디터 모달 콘텐츠 =====
   공통 T2Modal adaptive 셸이 모바일 바텀시트와 데스크톱 중앙 정렬,
   드래그 닫기 및 오버레이 수명 주기를 담당한다. */
.t2-image-editor-modal {
  /* box-sizing 누락으로 width:100% + padding:20px(상하좌우)가
     content-box 기준 계산되어 실제 폭이 "100% + 40px"이 되던 버그.
     left:0 은 고정된 채 오른쪽으로 40px 만큼 뷰포트 밖으로 밀려나가
     모바일에서 시트가 화면에 꽉 차지 못하고 한쪽으로 치우쳐 보였다.
     border-box 로 패딩을 폭 안쪽에 포함시켜 항상 정확히 100%(뷰포트
     전체 폭)를 채우도록 고정. */
  box-sizing: border-box;

  border-radius: var(--t2-img-radius-lg) var(--t2-img-radius-lg) 0 0;

  /* 708 G-4: 이 시트의 인셋 수치는 --t2-img-inset 하나가 소유한다. 아래
     safe-area 보정도 같은 변수를 읽으므로 상수를 복제하지 않는다. */
  --t2-img-inset: var(--t2-s5);
  padding: var(--t2-img-inset);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  width: 100%;
  max-width: 100%;
  max-height: 88vh;
  max-height: 88dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  animation: none;
  z-index: 1;
}

/* 자식 요소들도 동일한 box-sizing 규칙을 따르도록 통일 (내부 레이아웃이
   부모의 border-box 폭 기준으로 정확히 맞춰지도록). */
.t2-image-editor-modal *,
.t2-image-editor-modal *::before,
.t2-image-editor-modal *::after {
  box-sizing: border-box;
}

/* 바텀시트 드래그 핸들 — "아래로 끌어 닫기" 제스처의 시각적 단서.
   부모의 20px 패딩을 음수 마진으로 상쇄해 상단 끝까지 꽉 채운다. */
.t2-image-sheet-handle {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  margin: -20px -20px var(--t2-s3);
  padding: var(--t2-s3) 0 var(--t2-s1);
  cursor: grab;
  touch-action: none;
}
.t2-image-sheet-handle span {
  width: 36px;
  height: 4px;
  border-radius: 999px;

}
html[data-t2editor-theme="dark"] .t2-image-sheet-handle span {
  background: var(--t2-line);
}

.t2-image-editor-modal h3 {
  font-size: 18px;

  margin: 0 0 var(--t2-s4) 0;
  letter-spacing: -0.3px;
  flex-shrink: 0;
}

/* ===== 모달 본문(스크롤 전용) =====
   업로드 영역·드래그 힌트·미리보기 그리드만 여기 안에서 줄어들거나
   스크롤된다. NSFW 상태바/버튼/Powered-by는 이 밖(모달의 직계 자식)에
   있으므로 화면이 아무리 좁아도 항상 100% 렌더링되고 잘리지 않는다. */
.t2-image-editor-modal .t2-image-modal-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* 업로드 영역 */
/* 면·경계는 공통 어휘(.t2-upload-container)가 소유한다. 여기서 1px dashed 로
   다시 적으면 그 어휘가 "1px 은 표면의 경계선과 구별되지 않는다" 며 고른
   1.5px 이 되돌려진다 — 재서 확인했다. */
.t2-image-editor-modal .t2-image-upload-area {
  padding: var(--t2-s6) var(--t2-s4);
  text-align: center;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
  margin-bottom: var(--t2-s3);
  position: relative;
  flex-shrink: 0;

}

.t2-image-editor-modal .t2-image-upload-area:active {
  transform: scale(0.99);
}

.t2-image-editor-modal .t2-image-upload-area.drag-over {

  border-style: solid;
}

/* 표적 원의 기하(지름·글리프 크기·아래 여백)는 공통 어휘가 소유한다 —
   css/t2-visual-system.css 의 .t2-upload-container 와 compact 변형이다.
   여기서 다시 적으면 t2.plugin 이 t2.product 를 이겨, 36px 원 안의 글리프가
   상자와 같거나 커진다(같은 병으로 file 의 48px 이 실제로 잘렸다). */

/* 잉크는 공통 어휘가 정한다. 라이트에서만 제품색이 들어가 있었고(다크 블록은
   이미 --t2-ink 였다), 그래서 드롭존의 주 라벨과 안내가 둘 다 파랑이었다. */
.t2-image-editor-modal .t2-image-upload-text {
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: var(--t2-s1);
  letter-spacing: -0.15px;
}

.t2-image-editor-modal .t2-image-upload-hint {
  font-size: 11.5px;
  line-height: 1.5;
  letter-spacing: 0;
}

.t2-image-editor-modal input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;

  cursor: pointer;
}

/* 드래그 힌트 */
.t2-preview-drag-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--t2-s1);
  padding: var(--t2-s2) var(--t2-s3);
  margin-bottom: var(--t2-s2);

  font-size: 12px;
  background: var(--t2-product-wash);
  border-radius: var(--t2-radius-control);
  border: 1px solid var(--t2-product-wash);
  opacity: 0;
  transform: translateY(-4px);
  transition: color 0.25s ease, background-color 0.25s ease, border-color 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
  flex-shrink: 0;
}

.t2-preview-drag-hint.show {
  opacity: 1;
  transform: translateY(0);
}

.t2-preview-drag-hint .material-icons {
  font-size: 16px;
  color: var(--t2-ink-muted);
}

/* 미리보기 그리드 */
.t2-image-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: min-content;
  align-content: start;
  gap: var(--t2-s2);
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  max-height: 420px;
  margin-bottom: var(--t2-s4);
  border-radius: var(--t2-radius-control);
  contain: layout style;
}

.t2-image-preview-grid:empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--t2-line);
  border-radius: var(--t2-radius-structural);
}

.t2-image-preview-grid:empty::before {
  /* [I18N] content: attr(data-t2-empty-msg) 로 JS 에서 번역 주입, 폴백은 영문 */
  content: attr(data-t2-empty-msg, "Add image");
  color: var(--t2-line);
  font-size: 13px;
  font-weight: 500;
}

.t2-image-preview-grid::-webkit-scrollbar-track {
  background: transparent;
}

.t2-image-preview-grid::-webkit-scrollbar-thumb {
  background: var(--t2-inset);
  border-radius: 2px;
}

.t2-image-preview-grid::-webkit-scrollbar-thumb:hover {
  background: var(--t2-line);
}

/* 미리보기 아이템 */
.t2-preview-item {
  position: relative;
  aspect-ratio: 1 / 1;

  border-radius: var(--t2-radius-island);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;

  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
  min-height: 0;
  isolation: isolate;
}

.t2-preview-item:active {
  cursor: grabbing;
}

.t2-preview-item:hover {
  border-color: var(--t2-plugin-product, var(--t2-product));
  box-shadow: none;
}

.t2-preview-item.dragging {
  opacity: 0.5;
  transform: scale(0.95);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  z-index: 10;
  cursor: grabbing;
}

.t2-preview-item.drag-over {
  border-color: var(--t2-plugin-product, var(--t2-product));
  border-width: 1px;
  background: var(--t2-plugin-product-soft);
}

.t2-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* 모바일 브라우저 이미지 상호작용 메뉴(저장·공유·복사 등) 방지.
     pointer-events:none → 터치가 img 대신 부모 div에 전달되므로
     브라우저가 이미지 요소 전용 컨텍스트 메뉴를 띄우지 않음.
     -webkit-touch-callout:none → iOS Safari 롱프레스 콜아웃 차단.
     -webkit-user-drag:none    → 크롬/사파리 네이티브 이미지 드래그 차단. */
  pointer-events: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}

/* 순서 배지 */
.t2-preview-order {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 22px;
  height: 22px;
  padding: 0 var(--t2-s1);
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  border-radius: var(--t2-radius-island);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  z-index: 2;
  pointer-events: none;
  letter-spacing: -0.2px;
}

/* 삭제 버튼 */
.t2-preview-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  border: none;

  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
  opacity: 0;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}

.t2-preview-item:hover .t2-preview-remove,
.t2-preview-item:focus-within .t2-preview-remove {
  opacity: 1;
}

.t2-preview-remove:hover {
  background: rgba(239, 68, 68, 0.9);
  transform: scale(1.05);
}

.t2-preview-remove:active {
  transform: scale(0.95);
}

.t2-preview-remove .material-icons {
  font-size: 16px;
}

/* 업로드 인디케이터 */
.t2-upload-indicator {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  padding: var(--t2-s1) var(--t2-s2);
  border-radius: var(--t2-radius-island);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: var(--t2-s1);
  font-weight: 500;
}

.t2-upload-indicator .material-icons {
  font-size: 14px;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* NSFW 미리보기 상태 (활성화 시에만 표시) */

/* 안전 상태 - 초록색 */

/* 위험/의심 상태 - 빨간색 */

/* 로딩 상태 - 회색/노란색 아이콘 */

/* 오류 상태 - 노란색/주황색 */

/* NSFW 상태바 */

/* 메인 행 (아이콘 + 텍스트 + 배지) */

/* 스피닝 상태 */

/* 완료 상태 */

/* 로딩 배지 (모델 로드 퍼센트) */

/* 이미지 검사 로딩 */

/* 안전 상태 */

/* 위험/의심 상태 */

/* 오류 상태 */

/* 모델 로드 프로그레스 바 */

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* 다크모드 */
html[data-t2editor-theme="dark"] .t2-image-editor-modal {
  background: var(--t2-floating);
  box-shadow: var(--t2-img-modal-shadow-dark);
}

html[data-t2editor-theme="dark"] .t2-image-editor-modal h3 {
  color: var(--t2-ink);
}

html[data-t2editor-theme="dark"] .t2-image-editor-modal .t2-image-upload-area.drag-over {
  border-color: var(--t2-plugin-product, var(--t2-product));
  background: var(--t2-product-wash);
}

html[data-t2editor-theme="dark"] .t2-image-editor-modal .t2-image-upload-text {
  color: inherit;
}

html[data-t2editor-theme="dark"] .t2-image-editor-modal .t2-image-upload-hint {
  color: var(--t2-ink-muted);
}

html[data-t2editor-theme="dark"] .t2-preview-drag-hint {
  background: var(--t2-inset);
  border-color: var(--t2-line);
  color: var(--t2-ink-muted);
}

html[data-t2editor-theme="dark"] .t2-image-preview-grid:empty {
  background: transparent;
  border-color: var(--t2-line);
}

html[data-t2editor-theme="dark"] .t2-image-preview-grid:empty::before {
  color: var(--t2-ink-muted);
}

html[data-t2editor-theme="dark"] .t2-image-preview-grid::-webkit-scrollbar-thumb {
  background: var(--t2-line-strong);
}

html[data-t2editor-theme="dark"] .t2-image-preview-grid::-webkit-scrollbar-thumb:hover {
  background: var(--t2-line);
}

html[data-t2editor-theme="dark"] .t2-preview-item {
  border-color: var(--t2-line);
  background: var(--t2-surface);
}

html[data-t2editor-theme="dark"] .t2-preview-item:hover {
  border-color: var(--t2-plugin-product, var(--t2-product));
  box-shadow: none;
}

html[data-t2editor-theme="dark"] .t2-preview-item.drag-over {
  background: var(--t2-plugin-product-soft);
}

html[data-t2editor-theme="dark"] .t2-preview-order {
  background: rgba(255, 255, 255, 0.15);
}

html[data-t2editor-theme="dark"] .t2-preview-remove {
  background: rgba(255, 255, 255, 0.15);
}

html[data-t2editor-theme="dark"] .t2-preview-remove:hover {
  background: rgba(239, 68, 68, 0.9);
}

html[data-t2editor-theme="dark"] .t2-upload-indicator {
  background: rgba(255, 255, 255, 0.15);
}

/* 모바일 최적화 */
@media (max-width: 480px) {
  .t2-image-editor-modal {
    /* width/border-radius는 위쪽 바텀시트 기본값(100%, 위쪽만 둥근 모서리)을
       그대로 유지 — 예전엔 여기서 96%/전체 radius로 되돌려 다시 뜬 카드
       모양이 되어버렸다. padding/max-height만 초소형 화면에 맞게 조정. */
    padding: var(--t2-s4);
    max-height: 92vh;
    max-height: 92dvh;
  }

  .t2-image-sheet-handle {
    margin: -16px -16px var(--t2-s2);
  }

  .t2-image-editor-modal h3 {
    font-size: 17px;
    margin-bottom: var(--t2-s3);
  }

  .t2-image-editor-modal .t2-image-upload-area {
    padding: var(--t2-s5) var(--t2-s3);
    margin-bottom: var(--t2-s2);
  }

  .t2-image-editor-modal .t2-image-upload-text {
    font-size: 13px;
  }

  .t2-image-editor-modal .t2-image-upload-hint {
    font-size: 11px;
  }

  .t2-preview-drag-hint {
    font-size: 11px;
    padding: var(--t2-s1) var(--t2-s2);
    margin-bottom: var(--t2-s2);
  }

  .t2-preview-drag-hint .material-icons {
    font-size: 14px;
  }

  .t2-image-preview-grid {
    gap: var(--t2-s1);
    /* v: 예전엔 "92vh - 240px" 같은 고정 픽셀 예산으로 남은 공간을 추측했으나,
       NSFW 상태바처럼 나중에 추가된 요소의 높이가 반영되지 않아 좁은 화면에서
       상태바/버튼이 화면 밖으로 밀려 잘리는 문제가 있었다. 지금은 그리드가
       .t2-image-modal-body(flex:1) 안에서만 늘어나므로 max-height는 그
       부모의 100%로 두고, 실제 여백 계산은 flexbox가 알아서 하도록 맡긴다. */
    max-height: 100%;
    min-height: 90px;
    margin-bottom: var(--t2-s3);
  }

  .t2-preview-order {
    min-width: 20px;
    height: 20px;
    padding: 0 var(--t2-s1);
    border-radius: var(--t2-radius-island);
    font-size: 10px;
    top: 5px;
    left: 5px;
  }

  .t2-preview-remove {
    width: 24px;
    height: 24px;
    border-radius: var(--t2-radius-island);
    top: 5px;
    right: 5px;
    opacity: 1;
  }

  .t2-preview-remove .material-icons {
    font-size: 15px;
  }

  .t2-upload-indicator {
    padding: var(--t2-s1) var(--t2-s2);
    font-size: 10px;
    border-radius: var(--t2-radius-island);
  }

  .t2-upload-indicator .material-icons {
    font-size: 13px;
  }
}

/* 모바일 Medium */
@media (min-width: 481px) and (max-width: 640px) {
  .t2-image-editor-modal {
    /* 761px 미만은 전부 바텀시트 구간이므로 width는 기본값(100%) 유지,
       패딩만 살짝 넉넉하게. */
    --t2-img-inset: var(--t2-s4);
  }

  .t2-preview-remove {
    opacity: 1;
  }
}

/* 터치 디바이스 최적화 */
@media (hover: none) and (pointer: coarse) {
  .t2-preview-item {
    border-width: 1px;
  }

  .t2-preview-item:active {
    transform: scale(0.97);
    transition: transform 0.1s ease;
  }

  .t2-preview-remove {
    opacity: 1;
    width: 28px;
    height: 28px;
  }

  .t2-image-upload-area:active {
    transform: scale(0.985);
  }
}

/* 데스크톱에서는 작업 맥락을 유지하는 중앙 카드로 전환한다. */
@media (min-width: 761px) {
  .t2-image-editor-modal {
    position: static;
    left: auto;
    right: auto;
    bottom: auto;
    width: 94%;
    max-width: 440px;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: var(--t2-radius-island);
  }

  .t2-image-sheet-handle {
    display: none;
  }
}

/* 데스크톱 최적화 */
@media (min-width: 768px) {
  .t2-image-editor-modal {
    max-width: 480px;
    --t2-img-inset: var(--t2-s6);
  }

  .t2-image-editor-modal h3 {
    font-size: 19px;
    margin-bottom: var(--t2-s4);
  }

  .t2-image-preview-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--t2-s2);
    max-height: 450px;
  }

  .t2-preview-order {
    min-width: 24px;
    height: 24px;
    padding: 0 var(--t2-s2);
    font-size: 12px;
  }

  .t2-preview-remove {
    width: 28px;
    height: 28px;
  }

  .t2-preview-remove .material-icons {
    font-size: 17px;
  }
}

/* 가로 모드 모바일 */
@media (max-width: 896px) and (orientation: landscape) {
  .t2-image-editor-modal {
    max-height: 96vh;
    max-height: 96dvh;
  }

  .t2-image-preview-grid {
    max-height: 100%;
    min-height: 70px;
    grid-template-columns: repeat(5, 1fr);
  }

  .t2-image-editor-modal .t2-image-upload-area {
    padding: var(--t2-s4) var(--t2-s3);
  }

  .t2-preview-drag-hint {
    padding: var(--t2-s1) var(--t2-s2);
    margin-bottom: var(--t2-s2);
  }
}

/* 접근성 개선 */
@media (prefers-reduced-motion: reduce) {
  .t2-preview-item,
  .t2-preview-drag-hint,
  .t2-preview-remove,
  .t2-image-upload-area,
  .t2-image-editor-modal {
    transition: none;
  }

  @keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(0deg); }
  }
}

/* 고대비 모드 지원 */
@media (prefers-contrast: high) {
  .t2-preview-item {
    border-width: 1px;
  }

  .t2-image-upload-area {
    border-width: 1px;
  }

  html[data-t2editor-theme="dark"] .t2-preview-order,
  html[data-t2editor-theme="dark"] .t2-preview-remove,
  html[data-t2editor-theme="dark"] .t2-upload-indicator {
    background: rgba(255, 255, 255, 0.25);
  }
}

/* 추가 접근성 / 상태 구분 */
.t2-preview-remove:focus-visible {
  outline: 1px solid var(--t2-plugin-product, var(--t2-product));
  outline-offset: 2px;
}

/* SafeAI 법적 고지 버튼 (모달 외부 하단 우측) */

/* SafeAI 법적 고지 모달 */

/* ===== 이미지 블록 레이아웃 보정 =====
   core.css 의 공통 .t2-media-block 패딩/라인박스가 이미지 상하 공백으로
   보이는 문제를 image 플러그인 블록에만 제한해서 제거한다. */
/* [v10.0.0-beta2.3.5 - OVERFLOW FIX]
   box-sizing:border-box 추가 → border(1px) 로 인한 content area 축소가
   max-width:100% 계산에 반영되어 자식 컨테이너가 부모를 삐져나가지 않음. */
.t2-editor .t2-media-block.t2-image-block {
  padding: 0;
  line-height: 0;
  font-size: 0;
  overflow: visible;
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
}

.t2-editor .t2-media-block.t2-image-block > .t2-image-container {
  display: block;
  max-width: 100%;
  margin-top: 0;
  margin-bottom: 0;
  line-height: 0;
  font-size: 0;
  /* [OVERFLOW-FIX] container 가 img 보다 커지는 것을 하드웨어적으로 차단.
     controls/move-controls/upload-indicator 은 mediaBlock 자식(container 형제)이므로
     overflow:hidden 의 영향을 받지 않음. */
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
  overflow: hidden;
}

.t2-editor .t2-media-block.t2-image-block > .t2-image-container > img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0;
  vertical-align: top;
  /* [OVERFLOW-FIX] img 도 border-box 로 통일 (일관성) */
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
  /* [OVERFLOW-FIX] 모바일 브라우저 이미지 컨텍스트 메뉴/드래그 차단.
     .t2-preview-item img 와 동일 속성 적용 — 일관성 확보. */
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}

.t2-editor .t2-media-block.t2-image-block .t2-media-controls,
.t2-editor .t2-media-block.t2-image-block .t2-move-controls,
.t2-editor .t2-media-block.t2-image-block .t2-upload-indicator {
  font-size: 12px;
  line-height: normal;
}

/* 미리보기 확대 힌트 아이콘 */
.t2-preview-zoom-hint {
  position: absolute;
  bottom: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 50%;

  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  opacity: 0;
  -webkit-transition: opacity 0.18s ease;
          transition: opacity 0.18s ease;
  pointer-events: none;
  z-index: 2;
}
.t2-preview-item:hover .t2-preview-zoom-hint,
.t2-preview-item:focus-within .t2-preview-zoom-hint {
  opacity: 1;
}
/* 터치 환경에는 hover 가 없으므로 상시 표시한다. 여기서 opacity 를 낮추면
   스크림과 글리프가 함께 흐려져(그룹 합성) 대비가 2.17:1 까지 내려간다 —
   삭제 버튼이 이미 opacity:1 로 쓰고 있는 같은 판단 공식을 따른다 (704 제8·19항). */
@media (hover: none) {
  .t2-preview-zoom-hint {
    opacity: 1;
  }
}
.t2-preview-zoom-hint .material-icons {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.92);
}
html[data-t2editor-theme="dark"] .t2-preview-zoom-hint {
  background: rgba(255, 255, 255, 0.18);
}

/* 이미지 전체보기(확대 뷰) */
.t2-image-full-view {
  display: none;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  -webkit-box-flex: 1;
      -ms-flex: 1;
          flex: 1;
  min-height: 0;
  min-width: 0;
  margin-bottom: var(--t2-s4);
}
.t2-image-full-view.active {

  display: flex;
}

/* 전체보기 상단 조작 바 */
.t2-fv-topbar {

  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: justify;
      -ms-flex-pack: justify;
          justify-content: space-between;
  gap: var(--t2-s1);
  margin-bottom: var(--t2-s2);
  -ms-flex-negative: 0;
      flex-shrink: 0;
}
.t2-fv-back-btn {

  display: inline-flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  gap: var(--t2-s1);
  padding: var(--t2-s1) var(--t2-s2) var(--t2-s1) var(--t2-s2);
  background: var(--t2-workspace);
  border: 1px solid var(--t2-inset);

  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--t2-product-ink);
  font-family: inherit;
  -webkit-transition: background 0.15s, -webkit-transform 0.1s;
          transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
  -ms-flex-negative: 0;
      flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
.t2-fv-back-btn:hover { background: var(--t2-inset); }
.t2-fv-back-btn:active { background: var(--t2-line); -webkit-transform: scale(0.97); transform: scale(0.97); }
.t2-fv-back-btn .material-icons { font-size: 15px; line-height: 1; }

.t2-fv-counter {
  -webkit-box-flex: 1;
      -ms-flex: 1;
          flex: 1;
  text-align: center;
  font-size: 12px;
  color: var(--t2-ink-muted);
  white-space: nowrap;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.t2-fv-nav {

  display: flex;
  gap: var(--t2-s1);
  -ms-flex-negative: 0;
      flex-shrink: 0;
}
.t2-fv-nav-btn {
  width: 30px;
  height: 30px;
  background: var(--t2-workspace);
  border: 1px solid var(--t2-inset);

  cursor: pointer;

  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  color: var(--t2-product-ink);
  -webkit-transition: background 0.15s, -webkit-transform 0.1s;
          transition: background 0.15s, transform 0.1s;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.t2-fv-nav-btn:hover:not(:disabled) { background: var(--t2-inset); }
.t2-fv-nav-btn:active:not(:disabled) { -webkit-transform: scale(0.94); transform: scale(0.94); }
.t2-fv-nav-btn:disabled { opacity: 0.32; cursor: default; pointer-events: none; }
.t2-fv-nav-btn .material-icons { font-size: 18px; line-height: 1; }

/* 이미지 표시 영역 */
.t2-fv-image-area {
  -webkit-box-flex: 1;
      -ms-flex: 1;
          flex: 1;
  min-height: 0;
  min-width: 0;

  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  background: var(--t2-product-wash);
  border-radius: var(--t2-radius-island);
  overflow: hidden;
  position: relative;
}
.t2-fv-image-area img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  -o-object-fit: contain;
     object-fit: contain;
  border-radius: var(--t2-radius-control);
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
  -webkit-touch-callout: none;
}

/* 이미지 정보 바 (얇은 띠) */
.t2-fv-info-bar {
  -ms-flex-negative: 0;
      flex-shrink: 0;
  margin-top: var(--t2-s2);
  background: var(--t2-product-wash);
  border: 1px solid var(--t2-product-wash);
  border-radius: var(--t2-radius-control);
  padding: var(--t2-s1) var(--t2-s2);

  display: flex;
  -ms-flex-wrap: wrap;
      flex-wrap: wrap;
  gap: var(--t2-s1) var(--t2-s2);
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  min-width: 0;
  overflow: hidden;
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
}
.t2-fv-info-item {

  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  gap: var(--t2-s1);
  min-width: 0;
  max-width: 100%;
  -ms-flex-negative: 0;
      flex-shrink: 0;
}
.t2-fv-info-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--t2-ink-muted);
  background: var(--t2-product-wash);
  padding: var(--t2-s1) var(--t2-s1);
  border-radius: var(--t2-radius-control);
  white-space: nowrap;
  -ms-flex-negative: 0;
      flex-shrink: 0;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  line-height: 1.6;
}
.t2-fv-info-value {
  font-size: 11px;
  color: var(--t2-product-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  line-height: 1.4;
  font-weight: 500;
}
/* 파일명은 최대 너비 제한 (말줄임) */
.t2-fv-info-name {
  max-width: 140px;
}

/* 모바일: 정보 바 아이템 줄바꿈 최적화 */
@media (max-width: 400px) {
  .t2-fv-info-bar {
    padding: var(--t2-s1) var(--t2-s2);
    gap: var(--t2-s1) var(--t2-s2);
  }
  .t2-fv-info-label {
    font-size: 8.5px;
    padding: var(--t2-s1) var(--t2-s1);
  }
  .t2-fv-info-value {
    font-size: 10px;
  }
  .t2-fv-info-name {
    max-width: 110px;
  }
}
@media (max-width: 320px) {
  .t2-fv-info-item {
    width: calc(50% - 4px);
    -webkit-box-flex: 0;
        -ms-flex: 0 0 calc(50% - 4px);
            flex: 0 0 calc(50% - 4px);
  }
  .t2-fv-info-name {
    max-width: 90px;
  }
}

/* 다크모드 - 전체보기 */
html[data-t2editor-theme="dark"] .t2-fv-back-btn {
  background: var(--t2-surface);
  border-color: var(--t2-line);
  color: var(--t2-ink);
}
html[data-t2editor-theme="dark"] .t2-fv-back-btn:hover { background: var(--t2-line); }
html[data-t2editor-theme="dark"] .t2-fv-nav-btn {
  background: var(--t2-surface);
  border-color: var(--t2-line);
  color: var(--t2-ink);
}
html[data-t2editor-theme="dark"] .t2-fv-nav-btn:hover:not(:disabled) { background: var(--t2-line); }
html[data-t2editor-theme="dark"] .t2-fv-counter { color: var(--t2-ink-muted); }

/* 전체보기 편집 버튼 */
.t2-fv-edit-btn {
  width: 30px;
  height: 30px;

  border: 1px solid var(--t2-inset);

  cursor: pointer;

  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;

  -webkit-transition: background 0.15s, -webkit-transform 0.1s;
          transition: background 0.15s, transform 0.1s;
  padding: 0;
  -ms-flex-negative: 0;
      flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.t2-fv-edit-btn:hover { background: var(--t2-product-wash); color: var(--t2-plugin-product-strong, var(--t2-product-ink)); border-color: var(--t2-product-tone); }
.t2-fv-edit-btn:active { -webkit-transform: scale(0.94); transform: scale(0.94); }
.t2-fv-edit-btn .material-icons { font-size: 18px; line-height: 1; }
html[data-t2editor-theme="dark"] .t2-fv-edit-btn {
  background: var(--t2-surface);
  border-color: var(--t2-line);
  color: var(--t2-ink);
}
html[data-t2editor-theme="dark"] .t2-fv-edit-btn:hover {
  background: var(--t2-product-wash);
  color: var(--t2-product);
  border-color: var(--t2-plugin-product, var(--t2-product));
}
html[data-t2editor-theme="dark"] .t2-fv-image-area { background: var(--t2-surface); }
html[data-t2editor-theme="dark"] .t2-fv-info-bar {
  background: var(--t2-surface);
  border-color: var(--t2-line);
}
html[data-t2editor-theme="dark"] .t2-fv-info-label {
  background: var(--t2-surface);
  color: var(--t2-ink-muted);
}
/* 편집 버튼 (미리보기 아이템 하단 우측) */
.t2-preview-edit {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  border: none;

  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
  opacity: 0;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}

.t2-preview-item:hover .t2-preview-edit,
.t2-preview-item:focus-within .t2-preview-edit {
  opacity: 1;
}

.t2-preview-edit:hover {
  background: rgba(10, 132, 255, 0.9);
  transform: scale(1.08);
}

.t2-preview-edit:active {
  transform: scale(0.93);
}

.t2-preview-edit .material-icons {
  font-size: 14px;
}

/* 터치 환경: 삭제 버튼과 같은 공식 — 상시, 흐리지 않게. */
@media (hover: none) {
  .t2-preview-edit {
    opacity: 1;
  }
}

/* 다크모드 */
html[data-t2editor-theme="dark"] .t2-preview-edit {
  background: rgba(255, 255, 255, 0.18);
}
html[data-t2editor-theme="dark"] .t2-preview-edit:hover {
  background: rgba(10, 132, 255, 0.85);
}

/* 이미지 에디터 풀스크린 (JS inline에서 주입) */
/* image editor styles are injected via JS showImageEditorModal for encapsulation */

/* =====================================================================
   T2Editor / image plugin — Cross-device & cross-browser refinements
   (appended block: 모바일 주소창/홈인디케이터 회피, 태블릿/데스크톱 사용성,
    WebKit/Blink/Gecko/EdgeLegacy(IE) 호환, Powered by T2Editor 워터마크)
   ===================================================================== */

/* ---------- 1. Viewport height: 100vh 모바일 버그 회피 ----------------
   iOS Safari / Android Chrome 의 상·하단 동적 툴바가 100vh 를 침범하여
   모달 상단/하단이 잘리는 문제. dvh(동적), svh(small), lvh(large) 순으로
   점진적 폴백. 구형 WebKit 은 -webkit-fill-available, 그 외엔 90vh 유지. */
.t2-image-editor-modal {
  /* 1순위 폴백 (모든 구형 브라우저)  */
  max-height: 88vh;
  /* 2순위: iOS 12+ 사파리에서만 인식 */
  max-height: -webkit-fill-available;
  /* 3순위: 모던 브라우저 (Chrome 108+, Safari 15.4+, FF 101+) */
  max-height: min(88dvh, 90svh);
  /* 노치/홈인디케이터 영역만큼 안쪽 패딩 자동 보정 (바텀시트가 화면
     하단에 딱 붙으므로 모바일에서 특히 중요) */
  /* 708 C-1: 기본 상하 여백은 위와 같게 두고, 아래에는 노치 보정만 더한다. */
  padding-bottom: calc(var(--t2-img-inset) + env(safe-area-inset-bottom, 0px));
  /* IE 11 / Edge Legacy: flex 박스 shrink 버그 회피 */
  -ms-flex-negative: 1;
  /* 텍스트 자동 확대 방지 (iOS Safari 가로↔세로 회전 시) */
  -webkit-text-size-adjust: 100%;
     -moz-text-size-adjust: 100%;
      -ms-text-size-adjust: 100%;
          text-size-adjust: 100%;
}

/* 모달 오버레이가 떠 있는 동안 본문 스크롤 잠금이 미흡한 환경 보완.
   iOS Safari 의 rubber-band(고무줄) 튕김으로 모달이 시각적으로 흔들리는
   현상을 줄이고, Android Chrome 의 pull-to-refresh 도 차단한다. */
body.t2-image-upload-modal-open {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* 2. 미리보기 그리드 스크롤 & 모멘텀 */
.t2-image-preview-grid {
  /* iOS 의 부드러운 관성 스크롤 */
  -webkit-overflow-scrolling: touch;
  /* 그리드 내부 스크롤이 부모(모달/페이지)까지 전파되지 않게 */
  overscroll-behavior: contain;
  /* IE/Edge Legacy 스크롤바 자동 숨김 */
  -ms-overflow-style: -ms-autohiding-scrollbar;
  /* Firefox 얇은 스크롤바 */
  scrollbar-width: thin;
  scrollbar-color: var(--t2-line) transparent;
  /* aspect-ratio 미지원 구형 WebKit 폴백 (자식이 처리) */
  scroll-behavior: smooth;
}

/* aspect-ratio 미지원 브라우저 (iOS 14 이하, Edge 18 등) 폴백.
   1:1 정사각형을 padding-top trick 으로 유지. */
@supports not (aspect-ratio: 1 / 1) {
  .t2-preview-item {
    height: 0;
    padding-top: 100%;
    position: relative;
  }
  .t2-preview-item > img,
  .t2-preview-item > video {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
  }
}

/* 3. 버튼/입력 — WebKit/IE 외관 정규화 */
/* 주의: 기존에 명시된 .t2-btn / .t2-preview-remove 등 디자인을 깨지 않도록
   border-radius / font-size 는 건드리지 않고, 일관된 탭 하이라이트만 정리. */
.t2-image-editor-modal button,
.t2-image-editor-modal select,
.t2-image-editor-modal textarea {
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
     -moz-osx-font-smoothing: grayscale;
}

/* 텍스트 입력 계열만 — iOS 자동 확대(16px 미만 입력 포커스 시 페이지가
   확대되는 버그) 차단. 디자인용 input[type=file] 는 제외. */
.t2-image-editor-modal input:not([type="file"]):not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
.t2-image-editor-modal textarea {
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  font-size: max(16px, 1em);   /* iOS 줌 방지 최저 16px, 단 더 클 수 있음 */
  -webkit-tap-highlight-color: transparent;
}

/* select 의 OS 기본 화살표 제거(필요한 곳만) */
.t2-image-editor-modal select {
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* 액션 버튼류는 빠른 응답을 위해 더블탭 줌 비활성화 */
.t2-image-editor-modal .t2-btn,
.t2-image-editor-modal button[data-action],
.t2-preview-remove,
.t2-preview-edit,
.t2-image-upload-area {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}

/* [iOS⚠️] 터치 환경의 공식 최소 적중 영역은 44px로 유지한다. */
@media (hover: none) and (pointer: coarse) {
  .t2-image-editor-modal .t2-btn,
  .t2-image-editor-modal button[data-action] {
    min-height: 44px;
    min-width: 64px;
  }
  .t2-preview-remove,
  .t2-preview-edit {
    min-width: 44px;
    min-height: 44px;
  }
}

/* 4. 파일 input — 크로스 브라우저 숨김 */
/* IE/Edge Legacy 는 input[type=file] 의 "찾아보기" 텍스트가
   부모를 비집고 나오는 버그가 있다. 완전히 가리되 클릭은 살린다. */
.t2-image-editor-modal input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  /* IE 11 */
  filter: alpha(opacity=0);
  font-size: 0;
  color: transparent;
}
.t2-image-editor-modal input[type="file"]::-webkit-file-upload-button {
  visibility: hidden;
  display: none;
}

/* 5. 작은 화면(좁은 폰, 폴더블 접힘) */
@media (max-width: 360px) {
  .t2-image-editor-modal {
    /* 여기서도 width/border-radius는 바텀시트 기본값 유지, padding만 축소 */
    padding: var(--t2-s3);
  }
  .t2-image-sheet-handle {
    margin: -12px -12px var(--t2-s2);
  }
  .t2-image-editor-modal h3 {
    font-size: 16px;
    margin-bottom: var(--t2-s3);
  }
  .t2-image-preview-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--t2-s1);
  }
  .t2-image-editor-modal .t2-image-upload-area {
    padding: var(--t2-s4) var(--t2-s2);
  }
}

/* 6. 일반 모바일 가로 모드(낮은 높이) 추가 안전 */
@media (max-height: 480px) {
  .t2-image-editor-modal {
    /* 키보드/주소창 모두 떠도 모달이 잘리지 않도록 */
    max-height: min(96dvh, 96svh);
    padding-top: var(--t2-s3);
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .t2-image-editor-modal h3 {
    font-size: 15px;
    margin-bottom: var(--t2-s2);
  }
  .t2-image-editor-modal .t2-image-upload-area {
    padding: var(--t2-s3) var(--t2-s2);
  }
  .t2-preview-drag-hint {
    padding: var(--t2-s1) var(--t2-s2);
    margin-bottom: var(--t2-s1);
    font-size: 10px;
  }
  .t2-image-preview-grid {
    grid-template-columns: repeat(6, 1fr);
    max-height: calc(96dvh - 180px);
  }
}

/* 7. 태블릿 (포트레이트 ~ 일반) */
/* 7-인치~13-인치 태블릿: 작은 폰처럼 가로폭만 좁히지 말고
   콘텐츠 밀도를 늘려 한 번에 더 많은 미리보기가 보이도록. */
@media (min-width: 641px) and (max-width: 1024px) {
  .t2-image-editor-modal {
    margin: 0 auto;
    max-width: 620px;
    width: 92%;
    padding: var(--t2-s5) var(--t2-s6);
    border-radius: var(--t2-radius-island);
    max-height: min(88dvh, 90svh);
  }
  .t2-image-editor-modal h3 {
    font-size: 20px;
    margin-bottom: var(--t2-s4);
    letter-spacing: -0.4px;
  }
  .t2-image-preview-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--t2-s2);
    max-height: calc(88dvh - 280px);
  }
  .t2-image-editor-modal .t2-image-upload-area {
    padding: var(--t2-s6) var(--t2-s4);
  }
  .t2-image-editor-modal .t2-image-upload-text {
    font-size: 15px;
  }
  .t2-image-editor-modal .t2-image-upload-hint {
    font-size: 12px;
  }
}

/* 태블릿 가로 모드 (iPad Pro, Galaxy Tab 등) */
@media (min-width: 900px) and (max-width: 1366px) and (orientation: landscape) and (hover: none) {
  .t2-image-editor-modal {
    max-width: 720px;
  }
  .t2-image-preview-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* 8. 큰 데스크톱 (1280px+) */
@media (min-width: 1280px) and (hover: hover) and (pointer: fine) {
  .t2-image-editor-modal {
    max-width: 560px;
    --t2-img-inset: var(--t2-s6);
    border-radius: var(--t2-radius-island);
  }
  .t2-image-editor-modal h3 {
    font-size: 20px;
    margin-bottom: var(--t2-s5);
  }
  .t2-image-preview-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--t2-s3);
    max-height: 520px;
  }
  /* 데스크톱에서만 호버 상태 강조 */
  .t2-image-editor-modal .t2-image-upload-area:hover {
    box-shadow: none;
  }
}

/* 4K / 초광폭 모니터 */
@media (min-width: 1920px) and (hover: hover) {
  .t2-image-editor-modal {
    max-width: 640px;
  }
  .t2-image-preview-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* 9. iOS 노치/Dynamic Island 안전영역 */
/* 풀스크린 이미지 에디터(JS 인젝션) 측에서도 동일한 보호를 위해
   t2-image-full-view 가 떠 있을 때 본문 safe-area 도 함께 적용. */
@supports (padding: env(safe-area-inset-top)) {
  .t2-image-editor-modal, .t2-image-full-view{
    /* 노치 보정은 인셋을 올리기만 한다. 12px 상수를 바닥으로 쓰면 데스크톱에서
       설계값(20~24px)보다 작아져 위아래가 어긋난다 (708 C-1·G-4). */
    padding-top: max(env(safe-area-inset-top, 0px), var(--t2-img-inset, 12px));
    padding-left:  max(env(safe-area-inset-left,  0px), var(--t2-img-inset, 12px));
    padding-right: max(env(safe-area-inset-right, 0px), var(--t2-img-inset, 12px));
  }
}

/* SafeAI 하단 고지 버튼도 홈인디케이터 위로 끌어올림 */

/* 10. 호버 가능 환경 vs 터치 분리 강화 */
/* WebKit 의 -webkit-touch-callout: none 으로 길게 누름 시 컨텍스트 메뉴
   (이미지 저장 등) 방지. 편집 UX 가 손상되는 것을 막는다. */
.t2-image-editor-modal img,
.t2-preview-item,
.t2-preview-item img {
  -webkit-touch-callout: none;
}

/* 스타일러스 등 정밀 입력 환경에서만 호버 그림자 강조 */
@media (hover: hover) and (pointer: fine) {
  .t2-preview-item:hover {
    transform: translateY(-1px);
  }
}

/* 11. IE 11 / Edge Legacy 안전망 */
/* @supports 를 인식하지 못하는 IE 11 은 아래 블록 전체를 무시한다.
   반대로 모든 모던 브라우저에서만 적용되어 IE 의 깨진 grid 가 노출되지
   않도록, IE 가 이해 가능한 단순 폴백을 별도로 둔다. */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
  .t2-image-editor-modal {
    /* IE 는 dvh/svh/min() 미지원 → 안전한 vh 로 */
    max-height: 90vh;
    max-height: 90dvh;
    /* IE flex 박스 height 0 이슈 회피 */
    height: auto;
  }
  .t2-image-preview-grid {
    /* IE 는 grid 부분지원이라 flex 폴백으로 대체 */

    display: flex;
    -ms-flex-wrap: wrap;
        flex-wrap: wrap;
  }
  .t2-image-preview-grid > .t2-preview-item {
    -ms-flex: 0 0 calc(33.333% - 8px);
        flex: 0 0 calc(33.333% - 8px);
    margin: var(--t2-s1);
  }
  /* IE 는 backdrop-filter 미지원 → 불투명 배경으로 대체 */

}

/* 12. Powered by T2Editor 워터마크 */
.t2-image-editor-modal > .t2-btn-group {
  /* 상태바와 마찬가지로 모달의 직계 자식 — 항상 완전히 보여야 하는
     하단 고정 영역이므로 줄어들지 않게 고정한다. */
  flex-shrink: 0;
}

.t2-image-editor-poweredby {
  /* 모달 본문 영역 마지막에 살짝 자리. 버튼 그룹과 시각적 분리.    */
  margin-top: var(--t2-s2);
  margin-bottom: -2px;
  text-align: center;
  flex-shrink: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", "Apple SD Gothic Neo", "Noto Sans KR",
               Arial, sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2px;

  /* 눈에 덜 띄게 — 살짝 투명 */
  opacity: 0.55;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
  line-height: 1;
  /* 다크모드/저전력 모드에서도 자연스럽게 */
  transition: opacity 0.2s ease;
  /* IE 11: opacity 폴백 */
  filter: alpha(opacity=55);
}
.t2-image-editor-poweredby:hover {
  opacity: 0.85;
}
.t2-image-editor-poweredby .t2-pb-t2 {

  letter-spacing: 0;
}
.t2-image-editor-poweredby .t2-pb-editor {

  margin-left: var(--t2-s1);
}

/* 다크 테마 대응 */
html[data-t2editor-theme="dark"] .t2-image-editor-poweredby {
  color: var(--t2-ink-muted);
  opacity: 0.5;
}
html[data-t2editor-theme="dark"] .t2-image-editor-poweredby .t2-pb-t2 {
  color: var(--t2-warning);
}
html[data-t2editor-theme="dark"] .t2-image-editor-poweredby .t2-pb-editor {
  color: var(--t2-ink-muted);
}

/* 작은 화면에서는 더 작게 */
@media (max-width: 480px) {
  .t2-image-editor-poweredby {
    font-size: 9px;
    margin-top: var(--t2-s2);
    opacity: 0.5;
  }
}
/* 가로 모드에서는 공간 절약을 위해 더 옅게 */
@media (max-height: 480px) {
  .t2-image-editor-poweredby {
    font-size: 9px;
    margin-top: var(--t2-s1);
    opacity: 0.4;
  }
}
/* 데스크톱은 약간 더 또렷 */
@media (min-width: 1024px) and (hover: hover) {
  .t2-image-editor-poweredby {
    font-size: 11px;
    margin-top: var(--t2-s3);
  }
}

/* 고대비/접근성 모드에서는 충분히 보이게 */
@media (prefers-contrast: high) {
  .t2-image-editor-poweredby {
    opacity: 1;
    color: var(--t2-ink-muted);
  }
}
/* 모션 줄임 환경 */
@media (prefers-reduced-motion: reduce) {
  .t2-image-editor-poweredby {
    transition: none;
  }
}

/* 13. 풀스크린 이미지 편집기에도 노출 */
/* showImageEditorModal 가 만드는 풀스크린 컨테이너 우측 하단에 동일 표기
   (JS 측 수정 없이 CSS 만으로 가능하도록 ::after 사용) */
.t2-image-full-view.active::after {
  content: "Powered by T2Editor";
  position: absolute;
  right: calc(10px + env(safe-area-inset-right, 0px));
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: rgba(255, 255, 255, 0.32);
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Apple SD Gothic Neo", "Noto Sans KR", Arial, sans-serif;
  z-index: 5;
}

/* 14. Firefox-only 보정 */
/* Firefox 는 flex shrink 자식의 max-height 계산이 다르다. */
@-moz-document url-prefix() {
  .t2-image-editor-modal {
    min-height: 0;
  }
  .t2-image-preview-grid {
    min-height: 0;
  }
}

/* 15. 인쇄 시 워터마크/모달 숨김 */
@media print {
  .t2-image-editor-modal, .t2-image-full-view, .t2-image-editor-poweredby{
    display: none !important;
  }
}
.t2-image-preview-grid { -webkit-overflow-scrolling: touch; }

/* T2Editor /law official plugin design alignment */
/* Shared --t2-plugin-* tokens are owned by css/t2-foundation.css. */
.t2-dsc-service-brand {
  letter-spacing: -0.01em;
}
.t2-product-brand { white-space: nowrap; }

.t2-image-editor-modal { color: var(--t2-plugin-text); background: var(--t2-plugin-surface); border: 1px solid var(--t2-plugin-border); box-shadow: var(--t2-plugin-shadow); max-height: calc(100dvh - env(safe-area-inset-top)); }
.t2-image-editor-modal h3 { color: var(--t2-plugin-text); font-weight: 800; }
.t2-image-sheet-handle span { background: var(--t2-plugin-border-strong); }
/* 드롭존의 면·경계·표적 원의 잉크도 공통 어휘가 소유한다. 여기서 다시 적으면
   쉬는 상태의 중성 잉크가 제품색으로 고정되어 --t2-inset 위에서 4.32:1 로
   내려가고, hover/drag-over 의 잉크 전환도 막힌다 — 재서 확인했다. */
.t2-image-upload-text { color: var(--t2-plugin-text); font-weight: 750; }
.t2-image-upload-hint, .t2-preview-drag-hint { color: var(--t2-plugin-text-muted); }
.t2-preview-item { background: var(--t2-plugin-surface-raised); border: 1px solid var(--t2-plugin-border); box-shadow: none; } .t2-preview-item:focus-within { border-color: var(--t2-plugin-product); box-shadow: none; }
.t2-preview-remove, .t2-preview-edit, .t2-fv-back-btn, .t2-fv-nav-btn, .t2-fv-edit-btn, .t2-image-editor-modal .t2-btn { min-width: 44px; min-height: 44px; border-radius: var(--t2-plugin-radius-control); }
.t2-image-editor-modal .t2-btn[data-action="insert"] { color: var(--t2-plugin-on-action); background: var(--t2-plugin-action); border-color: var(--t2-plugin-action); font-weight: 750; }
.t2-image-editor-modal .t2-btn[data-action="cancel"] { color: var(--t2-plugin-text); background: var(--t2-plugin-surface-muted); border: 1px solid var(--t2-plugin-border); }
.t2-image-editor-poweredby { color: var(--t2-plugin-text-muted); }
.t2-image-editor-poweredby .t2-pb-t2 { color: var(--t2-plugin-dsc-ink); font-weight: 800; }
.t2-image-editor-poweredby .t2-pb-editor { color: var(--t2-plugin-product); font-weight: 800; }
.t2-fv-edit-btn { background: var(--t2-plugin-action); color: var(--t2-plugin-on-action); }
@media (max-width: 640px) {
  .t2-image-editor-modal { padding-bottom: calc(var(--t2-img-inset) + env(safe-area-inset-bottom)); }
  .t2-image-editor-modal input, .t2-image-editor-modal select, .t2-image-editor-modal textarea { font-size: 16px; } /* [iOS⚠️] */
}

/* =========================================================================
   T2Editor /law 706 — plugin scroll and native-control hardening
   ========================================================================= */
:is([class^="t2-image-"], [class*=" t2-image-"]):not([data-t2-modal-surface]) {
  max-width: 100%;
}
:is(:is([class^="t2-image-"], [class*=" t2-image-"]) :is(button, input, textarea, select), button[class^="t2-image-"], button[class*=" t2-image-"], input[class^="t2-image-"], input[class*=" t2-image-"], textarea[class^="t2-image-"], textarea[class*=" t2-image-"], select[class^="t2-image-"], select[class*=" t2-image-"]) {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}
:is(:is([class^="t2-image-"], [class*=" t2-image-"]) button, button[class^="t2-image-"], button[class*=" t2-image-"]) {
  -webkit-appearance: none;
  appearance: none;
}
:is(:is([class^="t2-image-"], [class*=" t2-image-"]) :is(input:not([type]), input[type="text"], input[type="search"], input[type="email"], input[type="url"], input[type="tel"], input[type="number"], input[type="password"], textarea, select), input:not([type])[class^="t2-image-"], input:not([type])[class*=" t2-image-"], input[type="text"][class^="t2-image-"], input[type="text"][class*=" t2-image-"], input[type="search"][class^="t2-image-"], input[type="search"][class*=" t2-image-"], input[type="email"][class^="t2-image-"], input[type="email"][class*=" t2-image-"], input[type="url"][class^="t2-image-"], input[type="url"][class*=" t2-image-"], input[type="tel"][class^="t2-image-"], input[type="tel"][class*=" t2-image-"], input[type="number"][class^="t2-image-"], input[type="number"][class*=" t2-image-"], input[type="password"][class^="t2-image-"], input[type="password"][class*=" t2-image-"], textarea[class^="t2-image-"], textarea[class*=" t2-image-"], select[class^="t2-image-"], select[class*=" t2-image-"]) {
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
}
:is(:is([class^="t2-image-"], [class*=" t2-image-"]) :is(button, input, textarea, select), button[class^="t2-image-"], button[class*=" t2-image-"], input[class^="t2-image-"], input[class*=" t2-image-"], textarea[class^="t2-image-"], textarea[class*=" t2-image-"], select[class^="t2-image-"], select[class*=" t2-image-"]):focus {
  outline: none;
}
:is(:is([class^="t2-image-"], [class*=" t2-image-"]) :is(button, input, textarea, select), button[class^="t2-image-"], button[class*=" t2-image-"], input[class^="t2-image-"], input[class*=" t2-image-"], textarea[class^="t2-image-"], textarea[class*=" t2-image-"], select[class^="t2-image-"], select[class*=" t2-image-"]):focus-visible {
  outline: 1px solid var(--t2-plugin-product, var(--t2-product));
  outline-offset: 2px;

}

.t2-image-preview-grid {
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  overscroll-behavior-y: contain;
  touch-action: pan-y pinch-zoom;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.t2-image-preview-grid::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* T2Editor /law 706 — plugin select indicator after native appearance reset */
:is(:is([class^="t2-image-"], [class*=" t2-image-"]) select, select[class^="t2-image-"], select[class*=" t2-image-"]):not([multiple]):not([size]) {
  padding-inline-end: max(32px, 2.25em);
  background: var(--t2-surface);
  background-position:
    calc(100% - 14px) calc(50% - 1px),
    calc(100% - 9px) calc(50% - 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
/* Custom drag surfaces own pointer movement and must not trigger native text/image selection. */
:where([data-t2-drag-surface], [draggable="true"], input[type="range"], [role="slider"],
  [class*="drag-handle"], [class*="resize-handle"], [class*="resizer"],
  [class*="crop-handle"], [class*="trim-handle"], [class*="seek-bar"],
  [class*="slider-thumb"], [class*="range-thumb"]) {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
:where([data-t2-drag-surface], [draggable="true"], input[type="range"], [role="slider"],
  [class*="drag-handle"], [class*="resize-handle"], [class*="resizer"],
  [class*="crop-handle"], [class*="trim-handle"], [class*="seek-bar"],
  [class*="slider-thumb"], [class*="range-thumb"]) img {
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none;
}
html.t2-drag-selection-active, html.t2-drag-selection-active body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

}
