/* 북마크 탭도 메모 탭과 동일한 둥근 네모 스타일 */
#bookmarkHeaderRow {
  margin-top: 8px;
  margin-bottom: 8px;
}
#bookmarkTabsContainer {
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  padding-left: 10px;
  margin-top: 0;
}
.bookmark-tab {
  background: #3a3a3a;
  padding: 8px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s,
    transform 0.15s ease;
  font-weight: 700;
  color: #ddd;
  font-size: 0.85rem;
  position: relative;
  z-index: 1;
  border: 1px solid transparent;
}
.bookmark-tab:hover {
  background: #4a4a4a;
}
.bookmark-tab.active {
  background: #111;
  color: #fff;
  border-color: #2a2a2a;
  z-index: 2;
}
.bookmark-tab.dragging {
  opacity: 0.3;
}
.bookmark-tab.placeholder {
  opacity: 1;
}
/* 이미지 모달 상단 아이콘 컨트롤 */
#imageModalControls {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 60;
  padding: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(8px);
}
.image-modal-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.15s ease;
}
.image-modal-icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.04);
}
.image-modal-icon-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}
#moveBookmarkTabSelect {
  position: absolute;
  top: 54px;
  left: 0;
  min-width: 140px;
  max-width: 220px;
  background: #1f1f1f;
  color: #fff;
  border: 1px solid #555;
  border-radius: 10px;
  padding: 8px 10px;
  display: none;
}
#imageModalControls.move-open #moveBookmarkTabSelect {
  display: block;
}

/* 북마크 Masonry 레이아웃 */
#image-grid {
  column-count: 2; /* 기본 2열 */
  column-gap: 1rem;
  margin-top: 1.5rem; /* mt-6 */
  display: block;
}
@media (min-width: 640px) {
  /* sm: 3열 */
  #image-grid {
    column-count: 3;
  }
}
@media (min-width: 1024px) {
  /* lg: 4열 */
  #image-grid {
    column-count: 4;
  }
}

/* 북마크 카드 스타일 */
.bookmark-card {
  position: relative;
  transition: transform 0.2s ease-in-out;
  background: #333;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem; /* 세로 간격 */
  break-inside: avoid; /* 카드 분할 방지 */
  width: 100%; /* Column 아이템으로 사용 */
  display: block;
}
.bookmark-card:hover {
  transform: translateY(-5px);
}

/* 콘텐츠 영역: 이미지/아이콘 높이에 따라 크기 결정 */
.bookmark-card .content {
  display: block;
  width: 100%;
  height: auto;
  overflow: hidden;
  background-color: #1a1a1a;
  /* 링크나 동영상 썸네일이 없을 때 최소 높이 보장 */
  min-height: 80px;
  position: relative; /* 오버레이를 위한 기준점 */
}

.bookmark-card img {
  position: static;
  width: 100%;
  height: auto; /* 실제 비율 사용 */
  display: block;
  /* 기본: 이미지가 잘리지 않고 전체가 보이도록 contain 설정 */
  object-fit: contain;
}

.bookmark-card .img-fit-cover {
  /* 비디오 썸네일용: 영역을 꽉 채우도록 cover 설정 */
  object-fit: cover;
  height: 100%; /* content의 높이를 꽉 채우도록 설정 */
}

/* 아이콘/텍스트 오버레이 */
.bookmark-card .icon-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 3rem;
}
/* 링크 북마크의 제목 표시 */
.bookmark-card .link-title-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  padding: 10px;
  text-align: center;
}
.bookmark-card .link-title-text {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 5px;
  word-break: break-all;
}
.bookmark-card .link-url-text {
  font-size: 0.75rem;
  opacity: 0.7;
  word-break: break-all;
}

/* 신규 Video title overlay (썸네일 없을 때) */
.bookmark-card .video-title-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(80, 0, 0, 0.7); /* Reddish background for video emphasis */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  padding: 10px;
  text-align: center;
}
.bookmark-card .video-title-text {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 5px;
  word-break: break-all;
}
.bookmark-card .video-url-text {
  font-size: 0.75rem;
  opacity: 0.7;
  word-break: break-all;
}

/* 인스타그램 스타일 (이제 직접 임베드 코드를 사용하므로 이 스타일은 사용하지 않음) */
.bookmark-card .instagram-overlay {
  display: none;
}

/* 인스타그램 임베드 짤림 방지: 임베드 콘텐츠가 부모 카드 너비를 넘지 않도록 설정 */
.bookmark-card .content > div[style*='max-width:540px'] {
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box; /* 패딩/보더 포함 너비 계산 */
}

/* 사이트별 구분 헤더 스타일 */
.domain-header {
  column-span: all; /* Masonry 레이아웃에서 전체 너비를 차지 */
  width: 100%;
  margin: 20px 0 10px;
  padding: 8px 0;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  border-bottom: 2px solid #555;
  text-align: left;
}

@media (max-width: 768px) {
  .domain-header {
    font-size: 1rem;
  }
}
/* 이미지 모달 스타일 */
#imageModal.modal {
  background: rgba(0, 0, 0, 0.7);
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
}
#imageModal .modal-content {
  background-color: transparent;
  padding: 0;
  box-shadow: none;
  /* Set max dimensions based on viewport to prioritize height */
  max-width: 90vw; /* 90% viewport width */
  max-height: 90vh; /* 90% viewport height (세로에 맞춤) */
  width: auto;
  height: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer; /* 모달 내용을 클릭해서 닫기 위해 커서 추가 */
}
#modalImage {
  /* Fill the constrained container while maintaining aspect ratio */
  width: auto;
  height: auto;
  max-width: 100%; /* 모달 콘텐츠 크기 내에서 최대화 */
  max-height: 100%; /* 모달 콘텐츠 크기 내에서 최대화 */
  object-fit: contain; /* Crucial: Ensures the whole image is visible within 90vw/90vh without being cut off */
}

/* 북마크 제목 수정 모달 스타일 */
#editTitleModal.modal {
  z-index: 1001;
}
#editTitleModal .modal-content {
  background: #2a2a2a;
  max-width: 400px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
