

/* === mob-hdr v2: 모바일 글쓰기 헤더 한 줄 배치 (정확한 V664 클래스 기준) ===
   V664 실제 헤더 자식:
     .hana-editor__back  / .hana-editor__title  / .hana-editor__save (임시저장)
     .v322-cancel-btn (취소)  / .hana-editor__submit (등록)
*/
@media (max-width: 768px) {
  /* 헤더 컨테이너 */
  .hana-sheet .hana-editor__header,
  .hana-editor__header {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 8px 10px !important;
    min-height: 48px !important;
    max-height: 56px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  /* 글쓰기 타이틀 완전 숨김 */
  .hana-editor__header .hana-editor__title {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* 뒤로 버튼 */
  .hana-editor__header .hana-editor__back {
    flex: 0 0 auto !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    font-size: 18px !important;
    line-height: 1 !important;
  }

  /* 임시저장: 좌측에서 떨어져 우측 그룹으로 (margin-left: auto로 우측 정렬) */
  .hana-editor__header .hana-editor__save {
    flex: 0 0 auto !important;
    margin-left: auto !important;
    height: 32px !important;
    padding: 0 10px !important;
    font-size: 13px !important;
    line-height: 30px !important;
    white-space: nowrap !important;
    border-radius: 6px !important;
  }

  /* 취소 버튼 (v322-cancel-btn) */
  .hana-editor__header .v322-cancel-btn {
    flex: 0 0 auto !important;
    height: 32px !important;
    padding: 0 10px !important;
    font-size: 13px !important;
    line-height: 30px !important;
    white-space: nowrap !important;
    border-radius: 6px !important;
  }

  /* 등록 버튼 (주황 강조) */
  .hana-editor__header .hana-editor__submit {
    flex: 0 0 auto !important;
    height: 32px !important;
    padding: 0 14px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 30px !important;
    white-space: nowrap !important;
    border-radius: 6px !important;
    background: #f97316 !important;
    color: #fff !important;
    border: 0 !important;
  }

  /* sheet 가로 스크롤 차단 */
  .hana-sheet { overflow-x: hidden !important; }
}

/* 360px 이하: 임시저장 숨김 (취소+등록만) */
@media (max-width: 380px) {
  .hana-editor__header .hana-editor__save { display: none !important; }
}

  /* mob-hdr v3 layout fix: 밴드/블로그 한 줄 + 32px 컴팩트 */
  .hana-editor__header .hana-editor__layout {
    flex: 0 0 auto !important;
    display: inline-flex !important;
    flex-direction: row !important;
    gap: 4px !important;
    height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    align-items: center !important;
  }
  .hana-editor__header .hana-editor__layout > *,
  .hana-editor__header .hana-editor__layout label,
  .hana-editor__header .hana-editor__layout-label,
  .hana-editor__header .hana-editor__layout-row,
  .hana-editor__header .hana-editor__layout button {
    height: 28px !important;
    padding: 0 10px !important;
    font-size: 12px !important;
    line-height: 28px !important;
    border-radius: 14px !important;
    white-space: nowrap !important;
    margin: 0 !important;
  }

/* === end mob-hdr === */


/* === just-stk: 양쪽정렬 제거 + 스티커 팝오버 위치 고정 === */

/* 1. 양쪽정렬 버튼 완전 제거 (모바일/데스크탑 모두) */
.hana-editor__format-btn[data-command="justifyFull"],
button[data-command="justifyFull"] {
  display: none !important;
}

/* 2. 스티커 팝오버: hidden 속성 풀렸을 때 정상 표시되도록 위치/크기/배경 강제 */
.hana-sticker-popover {
  position: fixed !important;
  z-index: 10000 !important;
  background: #fff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 12px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
  padding: 12px !important;
  width: 360px !important;
  max-width: calc(100vw - 24px) !important;
  max-height: 400px !important;
  overflow-y: auto !important;
  /* 기본 위치: 우하단 (toolbar 위에 띄움) */
}
/* [hidden] 속성 우선: 닫혀있을 때는 안 보이게 */
.hana-sticker-popover[hidden] {
  display: none !important;
}

/* 모바일: 전체 폭 활용 + 하단 sheet 스타일 */
@media (max-width: 768px) {
  .hana-sticker-popover {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: 50vh !important;
  }
}

/* 스티커 탭들 */
.hana-sticker-popover .hana-sticker-tabs {
  display: flex !important;
  gap: 4px !important;
  flex-wrap: wrap !important;
  padding: 0 0 8px 0 !important;
  border-bottom: 1px solid #e5e7eb !important;
  margin-bottom: 8px !important;
  position: sticky !important;
  top: 0 !important;
  background: #fff !important;
  z-index: 2 !important;
}
.hana-sticker-popover .hana-sticker-tab {
  flex: 0 0 auto !important;
  padding: 4px 10px !important;
  font-size: 12px !important;
  border-radius: 12px !important;
  background: #f3f4f6 !important;
  border: 0 !important;
  cursor: pointer !important;
}
.hana-sticker-popover .hana-sticker-tab.is-active {
  background: #f97316 !important;
  color: #fff !important;
}

/* 스티커 grid: 카테고리별 grid */
.hana-sticker-popover .hana-sticker-grid {
  display: none !important;
  grid-template-columns: repeat(8, 1fr) !important;
  gap: 4px !important;
}
.hana-sticker-popover .hana-sticker-grid.is-active {
  display: grid !important;
}
.hana-sticker-popover .hana-sticker-char {
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  font-size: 20px !important;
  line-height: 1 !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 6px !important;
  cursor: pointer !important;
}
.hana-sticker-popover .hana-sticker-char:hover {
  background: #fff7ed !important;
}

@media (max-width: 768px) {
  .hana-sticker-popover .hana-sticker-grid {
    grid-template-columns: repeat(7, 1fr) !important;
  }
  .hana-sticker-popover .hana-sticker-char {
    width: 36px !important;
    height: 36px !important;
    font-size: 22px !important;
  }
}
/* === end just-stk === */


/* === just-stk v2: popover 위치 보강 (모든 inline style + 부모 룰 이김) === */
html body .hana-sticker-popover {
  z-index: 99999 !important;
}
/* 데스크탑/모바일 공통: 화면 중앙 가까이 (toolbar 위로 띄움) */
html body .hana-sticker-popover:not([hidden]) {
  display: block !important;
  position: fixed !important;
  z-index: 99999 !important;
  /* stk-pos-fix v2: bottom/right/left/top 제거 - inline style 우선 */
  width: 420px !important;
  max-width: calc(100vw - 24px) !important;
  max-height: 60vh !important;
  background: #fff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 12px !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2) !important;
  overflow-y: auto !important;
  padding: 12px !important;
}
@media (max-width: 768px) {
  html body .hana-sticker-popover:not([hidden]) {
    /* stk-pos-fix v2: left/right/bottom 제거 */
    width: auto !important;
    max-width: none !important;
    max-height: 50vh !important;
  }
}
/* === end just-stk v2 === */
/* === stk-pos-fix v2 applied === */


/* === justify-full-remove: 양쪽정렬 버튼 완전 숨김 (모든 viewport) === */
html body .hana-editor__format-btn[data-command="justifyFull"],
html body button[data-command="justifyFull"] {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}
/* === end justify-full-remove === */


/* === stk-pos-fix v3 nuclear: inline style이 항상 이기도록 보장 === */
html body .hana-sticker-popover,
html body .hana-sticker-popover:not([hidden]),
html body div.hana-sticker-popover {
  /* 어떤 룰도 inline style을 못 이기게 unset */
  /* 주의: inline에서 설정한 top/left만 적용되어야 하므로 right/bottom은 unset, top/left는 unset 또는 inline값 */
}
/* === end stk-pos-fix v3 === */


/* === stk-pos-nuclear v4: inline left/top이 항상 적용되도록 보장 + right/bottom 제거 === */
html body .hana-sticker-popover[style*="top"],
html body .hana-sticker-popover[style*="left"] {
  right: auto !important;
  bottom: auto !important;
}
/* === end stk-pos-nuclear v4 === */


/* === blkrm-design v1: 미디어 제거 버튼 디자인 개선 + 새 미디어 wrap 스타일 === */
/* 모든 미디어 wrap을 hover 시 제거 버튼 강조 */
html body .hana-editor__body .hana-image-wrap,
html body .hana-editor__body .hana-kakao-mapblock {
  position: relative !important;
  transition: outline 0.15s ease;
}
html body .hana-editor__body .hana-image-wrap:hover,
html body .hana-editor__body .hana-kakao-mapblock:hover {
  outline: 2px solid #f97316;
  outline-offset: -2px;
  border-radius: 6px;
}

/* 제거 버튼 - 큰 원형 + 빨강 + 부드러운 전환 */
html body .hana-editor__body .hana-image-remove,
html body .hana-editor__body button.hana-image-remove {
  position: absolute !important;
  top: 8px !important;
  right: 8px !important;
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  margin: 0 !important;
  background: rgba(239, 68, 68, 0.92) !important;
  color: #fff !important;
  border: 2px solid #fff !important;
  border-radius: 50% !important;
  font-size: 18px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25) !important;
  z-index: 10 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.15s ease !important;
  opacity: 0.85 !important;
  user-select: none !important;
}
html body .hana-editor__body .hana-image-remove:hover,
html body .hana-editor__body button.hana-image-remove:hover {
  opacity: 1 !important;
  background: #dc2626 !important;
  transform: scale(1.1) !important;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4) !important;
}
html body .hana-editor__body .hana-image-remove:active,
html body .hana-editor__body button.hana-image-remove:active {
  transform: scale(0.95) !important;
}

/* 오디오 wrap 디자인 - 회색 배경에 컴팩트 */
html body .hana-editor__body .hana-audio-wrap {
  background: #f3f4f6 !important;
  border-radius: 8px !important;
  padding: 8px !important;
  margin: 8px 0 !important;
}
html body .hana-editor__body .hana-audio-wrap audio {
  width: 100% !important;
  max-width: 480px !important;
}

/* 파일 wrap (a[download]) 디자인 - 인라인 칩 */
html body .hana-editor__body .hana-file-wrap {
  display: inline-flex !important;
  align-items: center !important;
  background: #fff7ed !important;
  border: 1px solid #fed7aa !important;
  border-radius: 6px !important;
  padding: 6px 32px 6px 10px !important;
  margin: 2px 4px 2px 0 !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
}
html body .hana-editor__body .hana-file-wrap a[download] {
  color: #c2410c !important;
  text-decoration: none !important;
  font-weight: 500 !important;
}
html body .hana-editor__body .hana-file-wrap a[download]:hover {
  text-decoration: underline !important;
}
/* 파일 wrap의 제거 버튼은 좀 더 작게 */
html body .hana-editor__body .hana-file-wrap .hana-image-remove {
  width: 22px !important;
  height: 22px !important;
  top: 50% !important;
  right: 4px !important;
  transform: translateY(-50%) !important;
  font-size: 14px !important;
}
html body .hana-editor__body .hana-file-wrap .hana-image-remove:hover {
  transform: translateY(-50%) scale(1.1) !important;
}

/* 모바일에서 제거 버튼 더 크게 (터치하기 쉽게) */
@media (max-width: 768px) {
  html body .hana-editor__body .hana-image-remove,
  html body .hana-editor__body button.hana-image-remove {
    width: 36px !important;
    height: 36px !important;
    top: 6px !important;
    right: 6px !important;
    opacity: 1 !important;  /* 모바일은 hover 없으니 항상 표시 */
    font-size: 20px !important;
  }
  html body .hana-editor__body .hana-file-wrap .hana-image-remove {
    width: 24px !important;
    height: 24px !important;
    font-size: 15px !important;
  }
}
/* === end blkrm-design v1 === */


/* === imgtb-fix v1: 이미지 도구창 가시성 + 모바일 overflow 개선 === */

/* 1) 도구창 컨테이너 - 더 진한 배경 + 그림자 강화 + viewport 안에 들어오게 */
html body .hana-editor__body .hana-image-toolbar {
  background: #1f2937 !important;        /* 어두운 회색 (slate-800) */
  border: 1px solid #374151 !important;
  border-radius: 8px !important;
  padding: 4px !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25) !important;
  z-index: 100 !important;
  /* viewport 안에 강제로 들어오게 - 좌우 여백 보장 */
  max-width: calc(100vw - 16px) !important;
  /* 위치는 기존 그대로 (top: -42px, left: 50%, translateX(-50%)) */
}

/* 2) 도구창 버튼 - 명시적 흰 글자, 호버 시 주황 */
html body .hana-editor__body .hana-image-toolbar button {
  background: transparent !important;
  color: #f9fafb !important;             /* 거의 흰색 (gray-50) - 어두운 배경에 잘 보임 */
  border: 0 !important;
  border-radius: 6px !important;
  width: 36px !important;
  height: 32px !important;
  padding: 0 !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}
html body .hana-editor__body .hana-image-toolbar button:hover {
  background: #f97316 !important;        /* 주황 배경 */
  color: #fff !important;
}
html body .hana-editor__body .hana-image-toolbar button.is-active,
html body .hana-editor__body .hana-image-toolbar button[aria-pressed="true"] {
  background: #f97316 !important;
  color: #fff !important;
}

/* 3) 구분선 - 어두운 배경에 보이도록 밝게 */
html body .hana-editor__body .hana-image-toolbar__sep {
  background: #4b5563 !important;        /* gray-600 */
  width: 1px !important;
  margin: 4px 4px !important;
}

/* 4) 모바일 도구창 가려짐 fix */
@media (max-width: 768px) {
  html body .hana-editor__body .hana-image-toolbar {
    /* 더 컴팩트하게 + 화면 안에 강제 */
    top: -40px !important;
    bottom: auto !important;
    padding: 3px !important;
    gap: 1px !important;
    /* viewport 안에서 절대 잘리지 않도록 - 도구창은 이미지 상단 중앙 정렬 유지 */
    max-width: calc(100vw - 20px) !important;
    overflow-x: auto !important;          /* 정 안 들어오면 가로 스크롤 */
    -webkit-overflow-scrolling: touch !important;
  }
  html body .hana-editor__body .hana-image-toolbar button {
    width: 34px !important;
    height: 30px !important;
    font-size: 14px !important;
    flex: 0 0 auto !important;
  }
  html body .hana-editor__body .hana-image-toolbar__sep {
    flex: 0 0 auto !important;
  }
  
  /* 만약 이미지가 작아서 도구창이 잘리면 도구창 위치 조정 - 이미지 좌측 정렬 */
  html body .hana-editor__body .hana-image-wrap.is-selected .hana-image-toolbar {
    left: 50% !important;
    transform: translateX(-50%) !important;
    /* 단 viewport 가장자리에서는 위치 조정 (CSS만으로는 한계, JS 도움 필요할 수 있음) */
  }
}

/* 5) 이미지 wrap의 is-selected 상태에서 wrap 자체가 화면 밖으로 안 나가게 */
@media (max-width: 768px) {
  html body .hana-editor__body .hana-image-wrap {
    max-width: 100% !important;
  }
  html body .hana-editor__body .hana-image-wrap img,
  html body .hana-editor__body .hana-image-wrap video {
    max-width: 100% !important;
    height: auto !important;
  }
}
/* === end imgtb-fix v1 === */


/* === imgbound v1: 글 보기 본문 내 미디어가 컨테이너 경계 초과 방지 === */
/* 본문 카드 안의 모든 미디어 wrap을 컨테이너 폭 안으로 강제 - 단 그리드(갤러리) 모드는 제외 */
html body .hana-card__body .hana-image-wrap,
html body .hana-card__body .hana-video-wrap,
html body .hana-card__body .hana-audio-wrap,
html body .hana-card__body .hana-file-wrap,
html body .hana-card__body .hana-kakao-mapblock,
html body .hana-card__body .hana-media__item {
  max-width: 100% !important;
  width: auto !important;
  height: auto !important;
  box-sizing: border-box !important;
}

/* 미디어 wrap 안의 실제 미디어 요소도 컨테이너 폭으로 제한 */
html body .hana-card__body .hana-image-wrap img,
html body .hana-card__body .hana-image-wrap video,
html body .hana-card__body .hana-video-wrap video,
html body .hana-card__body img.has-v314-media,
html body .hana-card__body video.has-v314-media,
html body .hana-card__body audio {
  max-width: 100% !important;
  width: auto !important;
  height: auto !important;
  display: block !important;
}

/* 카드 본문 자체는 가로 overflow를 잘라서 안전망 (예외 케이스 대비) */
html body .hana-card__body {
  max-width: 100% !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}

/* float 모드는 max-width 50% 그대로 유지 (이미 feed.css 5172/5175에 정의) - 추가 보강 */
html body .hana-card__body .hana-image-wrap.is-float-left,
html body .hana-card__body .hana-image-wrap.is-float-right {
  max-width: 50% !important;
}

/* 그리드(갤러리) 모드는 제외 - feed.css 1119가 width:100% height:100%으로 강제하는 룰 보존 */
/* (is-grid 안에서는 이 규칙들이 더 높은 specificity로 위 imgbound를 못 이김에 주의) */

/* 모바일에서 추가 안전망 */
@media (max-width: 768px) {
  html body .hana-card__body .hana-image-wrap,
  html body .hana-card__body .hana-video-wrap,
  html body .hana-card__body .hana-kakao-mapblock {
    max-width: 100% !important;
    width: 100% !important;
  }
  /* 모바일에서는 float-left/right도 100% (좁은 화면에서 텍스트 흐름 깨짐 방지) */
  html body .hana-card__body .hana-image-wrap.is-float-left,
  html body .hana-card__body .hana-image-wrap.is-float-right {
    float: none !important;
    max-width: 100% !important;
    margin: 8px 0 !important;
  }
}
/* === end imgbound v1 === */


/* === mapblock-protect-css v1: 카카오 지도 타일 img 보호 (feed.css의 광범위 img 룰 차단) ===
   카카오 지도는 mapblock 안에 absolute positioned img 타일을 그려서 지도를 표현.
   feed.css의 `.hana-editor__body img:not(...) { width: 700px !important }` 류 룰이
   카카오 타일에 적용되면 타일이 거대해지고 부모 div가 0이 되어 회색 화면이 됨.
   여기서 카카오 mapblock + map-embed 안의 모든 img/canvas의 width/height/max-width를
   inherit / auto / none으로 강제하여 카카오가 직접 설정한 inline style 보호. */
html body .hana-editor__body .hana-kakao-mapblock img,
html body .hana-editor__body .hana-kakao-mapblock canvas,
html body .hana-card__body .hana-kakao-mapblock img,
html body .hana-card__body .hana-kakao-mapblock canvas,
html body .hana-kakao-mapblock img,
html body .hana-kakao-mapblock canvas {
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  object-fit: unset !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* mapblock 자체는 컨테이너 폭 따라가도록 (이미지처럼 처리 X) */
html body .hana-editor__body .hana-kakao-mapblock,
html body .hana-card__body .hana-kakao-mapblock {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;
  overflow: hidden !important;
  position: relative !important;
}

/* mapblock 내부 __map 영역은 카카오 지도가 사이즈 관리 - 우리는 손대지 않음 */
/* 다만 최소 높이 보장 (카카오 지도가 사이즈 0으로 시작 안 하도록) */
html body .hana-editor__body .hana-kakao-mapblock__map,
html body .hana-card__body .hana-kakao-mapblock__map {
  width: 100% !important;
  min-height: 280px !important;
  position: relative !important;
}
/* === end mapblock-protect-css v1 === */

/* HANA-M-FIX-MOBILE-SHEET — Phase M Step 4
   모바일에서 #hana-editor-sheet 헤더가 viewport 위로 잘리는 문제 fix.
   원인: feed.css의 .hana-sheet__panel { margin: 40px auto } 룰이 (min-width: 768px) 안에 있어
        모바일에서는 자동 margin이 없는데도 어딘가에서 12px margin이 남고,
        max-height: calc(100vh - 80px) 룰도 적용 안 됨 → 패널이 viewport보다 커져 헤더가 위로 잘림.
   해결: 모바일에서 패널을 full-screen 시트로 만들고, 내부 스크롤은 .hana-editor__body가 담당.
*/
@media (max-width: 768px) {
    html body #hana-editor-sheet.hana-sheet {
        align-items: stretch !important;
        padding: 0 !important;
    }
    html body #hana-editor-sheet .hana-sheet__panel {
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }
    html body #hana-editor-sheet .hana-editor {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        height: auto !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }
    html body #hana-editor-sheet .hana-editor__header {
        flex: 0 0 auto !important;
        position: sticky !important;
        top: 0 !important;
        background: #fff !important;
        z-index: 5 !important;
    }
    html body #hana-editor-sheet .hana-editor__meta {
        flex: 0 0 auto !important;
    }
    html body #hana-editor-sheet .hana-editor__toolbar,
    html body #hana-editor-sheet .hana-editor__font-toolbar {
        flex: 0 0 auto !important;
    }
    html body #hana-editor-sheet .hana-editor__body {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    html body #hana-editor-sheet .hana-editor__options {
        flex: 0 0 auto !important;
    }
}
/* end HANA-M-FIX-MOBILE-SHEET */
