.item-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  z-index: 100000;
}

/* 스토리지 그리드 이미지 썸네일: 모바일 포함 영역 꽉 차게 고정 */
.item .img-wrap img.storage-grid-image-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover !important;
  object-position: center;
  display: block;
}

@media (max-width: 767.98px) {
  .item .img-wrap img.storage-grid-image-thumb {
    object-fit: cover !important;
  }
}

.item-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-modal .modal-overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  cursor: pointer;
}

.item-modal .modal-content {
  position: relative;
  width: 80%;
  max-width: 960px;
  max-height: calc(100vh - 100px);
  margin: 50px auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.item-modal .modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.item-modal .modal-close:hover {
  background: rgba(0, 0, 0, 0.12);
}

.item-modal .modal-body {
  padding: 48px 24px 24px;
  overflow-y: auto;
  max-height: calc(100vh - 120px);
}

.item-modal .modal-title {
  margin: 0 0 16px;
  font-size: 1.35rem;
  font-weight: 700;
}

.item-modal .modal-viewer {
  margin-bottom: 20px;
}

.item-modal .modal-meta {
  font-size: 0.9375rem;
}

@media (max-width: 768px) {
  .item-modal .modal-content {
    width: 94%;
    margin: 24px auto;
    max-height: calc(100vh - 48px);
  }
}

/* 동영상 미리보기 */
.item .img-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #1a1a1a;
  display: block;
  pointer-events: none;
  transition: 0.5s;
}
.item:hover .img-wrap video {
  transform: scale(1.05);
}

/* PDF 썸네일: Ghostscript 1장 JPEG(캐시) — 그리드에 스크롤 없이 이미지만 */
.item .img-wrap .storage-grid-pdf-poster {
  width: 100%;
  height: 100%;
  min-height: 198px;
  object-fit: cover;
  object-position: 50% 0;
  display: block;
  pointer-events: none;
  background: #f0f0f0;
}

/* 서버 썸네일 없을 때: pdf.js로 채우기 전 플레이스홀더 */
.item .img-wrap .storage-pdf-thumb-js {
  position: relative;
  width: 100%;
  min-height: 198px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eceef2;
  overflow: hidden;
}
.item .img-wrap .storage-pdf-thumb-js .storage-pdf-thumb-placeholder {
  position: absolute;
  z-index: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: #8b90a0;
  letter-spacing: 0.02em;
}
.item .img-wrap .storage-pdf-thumb-js .storage-grid-pdf-poster-js {
  position: relative;
  z-index: 1;
  min-height: 198px;
  width: 100%;
  object-fit: cover;
  object-position: 50% 0;
}

/* 기록 rform: board-top-util 아래 생산연대·기록유형(접이) — 상단 강선은 board-top-util 만 */
.record-rform-filters {
  margin: 0 0 18px;
  padding: 2px 0 12px;
  border-top: 0;
  border-bottom: 1px solid #e3e3e3;
}

.record-rform-filters__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: flex-start;
}

.record-rform-filter {
  position: relative;
  min-width: 200px;
  max-width: 100%;
  border: 1px solid #e3e3e3;
  background: #fff;
  border-radius: 3px;
  font-size: 13px;
}

.record-rform-filter > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  min-height: 40px;
  box-sizing: border-box;
}

.record-rform-filter > summary::-webkit-details-marker {
  display: none;
}

.record-rform-filter__k {
  color: #666;
  font-weight: 600;
}

.record-rform-filter__v {
  color: #111;
  flex: 1;
  text-align: right;
  font-weight: 600;
}

.record-rform-filter__ic {
  color: #999;
  font-size: 10px;
  line-height: 1;
}

.record-rform-filter[open] {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  z-index: 3;
}

.record-rform-filter__panel {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 2px;
  padding: 8px;
  background: #fff;
  border: 1px solid #e3e3e3;
  border-radius: 3px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(100vw - 32px, 580px);
}

.record-rform-filter__opt {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  max-width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border-radius: 2px;
  background: #f3f4f6;
  color: #333;
  text-decoration: none;
  font-size: 12px;
  line-height: 1.3;
}

.record-rform-filter__opt:hover {
  background: #e8eaef;
  color: #111;
}

.record-rform-filter__opt.is-active {
  background: var(--point-color, #c44);
  color: #fff;
}

.record-rform-filter__txt {
  flex: 1 1 auto;
  min-width: 0;
}

.record-rform-filter__cnt {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  opacity: 0.7;
  flex: 0 0 auto;
}

.record-rform-filter__opt.is-active .record-rform-filter__cnt {
  opacity: 0.9;
  color: inherit;
}

@media (max-width: 600px) {
  .record-rform-filter {
    min-width: calc(50% - 6px);
    flex: 1 1 140px;
  }
}

/* 모바일(세로): 그리드 썸 = 작은 정사각, 세로 늘어짐(198px) 제거 — 화면만 가로로 밀리지 않게 */
@media (max-width: 767.98px) {
  body.items.browse .archive-grid,
  .archive-grid {
    min-width: 0;
  }
  .archive-grid .item {
    min-width: 0;
  }
  .archive-grid .item > a {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .item .img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    min-height: 0 !important;
    max-height: none;
    overflow: hidden;
    background: #eceef2;
  }
  .item .img-wrap img,
  .item .img-wrap video,
  .item .img-wrap .storage-grid-video,
  .item .img-wrap .storage-pdf-thumb-js,
  .item .img-wrap.item-thumb-placeholder,
  .item .item-thumb-placeholder {
    min-height: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
    object-position: center;
  }
  .item .img-wrap .storage-grid-pdf-poster,
  .item .img-wrap .storage-grid-pdf-poster-js {
    min-height: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    object-position: center;
  }
  .item .txt-title {
    font-size: 0.78rem;
    line-height: 1.25;
    padding: 0.3rem 0.15rem 0.15rem;
    word-break: break-word;
  }
  .record-rform-filters {
    margin: 0 0 10px;
    padding: 2px 0 8px;
  }
  .record-rform-filters__inner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  /* 닫힌 상태: 검색창(.search-wrap)과 동일 40px 한 줄(클릭 시에만 패널이 펼쳐짐) */
  .record-rform-filters__inner .record-rform-filter {
    min-width: 0 !important;
    max-width: 100%;
    width: 100%;
    flex: 0 0 auto !important;
  }
  .record-rform-filter > summary {
    min-height: 0;
    height: 40px;
    max-height: 40px;
    padding: 0 10px 0 12px;
    box-sizing: border-box;
    font-size: 12px;
    line-height: 1.2;
  }
  .record-rform-filter__k,
  .record-rform-filter__v {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .record-rform-filter__k {
    flex: 0 0 auto;
    max-width: 45%;
  }
  .record-rform-filter__v {
    text-align: right;
  }
  .record-rform-filter__ic {
    flex: 0 0 auto;
  }
  .record-rform-filter__panel {
    max-width: 100%;
  }
}


/* Extracted from browse-item-modal-viewer.php for CSP compatibility. */
.vm-fm-line {
  font-size: 0.98rem;
  line-height: 1.5;
  margin: 0 0 0.35em 0;
  word-break: break-word;
}
.vm-fm-line--desc {
  line-height: 1.6;
  margin: 0;
  margin-top: 0.5rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(0,0,0,0.08);
}
.vm-fm-label {
  color: var(--vm-text-muted, #5c6068);
}
.vm-fm-value {
  font-weight: 600;
  color: var(--vm-ink, #1a1d24);
}
.vm-files-index-meta {
  font-size: 0.98rem;
  color: var(--vm-text-muted, #6b6e78);
}
.vm-meta-loading {
  opacity: 0.6;
  padding: 12px 0;
}
/* 기록 페이지·style.css(:root)와 동일 계열 */
#item-modal {
  --vm-surface: var(--lux-ivory, #ffffff);
  --vm-muted: var(--lux-ivory-muted, #f5f5f5);
  --vm-line: var(--lux-line, #e1e1e1);
  --vm-line-strong: var(--lux-line-strong, rgba(44, 46, 53, 0.2));
  --vm-ink: var(--lux-charcoal, #2c2e35);
  --vm-text: var(--lux-text, #2c2e35);
  --vm-text-muted: var(--lux-text-muted, #6b6e78);
  --vm-point: var(--site-point, #00afec);
  --vm-point-soft: var(--site-point-soft, rgba(0, 175, 236, 0.14));
  --vm-accent-warm: var(--lux-accent, #857960);
  --vm-stage: #252830;
  --vm-stage-deep: #1a1c22;
  --vm-shadow: var(--lux-shadow, rgba(44, 46, 53, 0.12));
  --vm-radius: 10px;
  --vm-radius-sm: 6px;
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100000;
  align-items: center;
  justify-content: center;
  font-family: 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}
#item-modal.active { display: flex; }
#item-modal .modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(44, 46, 53, 0.52);
  /* blur 제거: 모달 열림 시 GPU·합성 비용 줄임 */
}
#item-modal .viewer-modal {
  position: relative;
  width: 88vw;
  min-height: 0;
  height: 95dvh;
  max-height: 95dvh;
  max-width: none;
  background: var(--vm-surface);
  border-radius: var(--vm-radius);
  border: 1px solid var(--vm-line);
  box-shadow:
    0 4px 6px var(--vm-shadow),
    0 22px 48px rgba(44, 46, 53, 0.14);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1;
  color: var(--vm-text);
}
#item-modal .viewer-modal.is-fullscreen {
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
}
#item-modal .viewer-mo-topbar {
  display: none;
}
#item-modal .viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--vm-line);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--vm-surface) 0%, var(--vm-muted) 100%);
}
#item-modal .viewer-header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#item-modal .viewer-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#item-modal .item-nav {
  padding: 8px 16px;
  border: 1px solid var(--vm-line);
  border-radius: var(--vm-radius-sm);
  background: var(--vm-muted);
  color: var(--vm-text);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
#item-modal .item-nav:hover:not(:disabled) {
  border-color: var(--vm-point);
  color: var(--vm-point);
  background: var(--vm-point-soft);
  box-shadow: 0 0 0 1px var(--vm-point-soft);
}
#item-modal .item-nav:disabled { opacity: 0.38; cursor: not-allowed; }
#item-modal .item-nav.item-prev,
#item-modal .item-nav.item-next {
  display: none !important;
}
#item-modal #viewer-title {
  flex: 1;
  margin: 0;
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  font-weight: 600;
  text-align: center;
  min-width: 0;
  color: var(--vm-text);
  letter-spacing: -0.04em;
  line-height: 1.35;
}
#item-modal #viewer-maximize,
#item-modal #viewer-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--vm-radius-sm);
  background: transparent;
  color: var(--vm-text-muted);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
#item-modal #viewer-close.viewer-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 90px;
  height: 44px;
  padding: 0 14px;
  box-sizing: border-box;
  color: #f8f9fa;
  background: #1e2329;
  border: 1px solid #0f1216;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
#item-modal .viewer-close__label {
  display: inline;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
#item-modal .viewer-close__x {
  display: none;
  font-size: 1.15rem;
  line-height: 1;
  font-weight: 600;
}
#item-modal #viewer-maximize {
  font-size: 0.95rem;
}
#item-modal #viewer-maximize:hover,
#item-modal #viewer-close:hover {
  color: var(--vm-point);
  background: transparent;
}
#item-modal #viewer-close.viewer-close-btn:hover {
  color: #fff;
  background: #0f1216;
  border-color: var(--vm-point);
}

#item-modal .viewer-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: var(--vm-surface);
}
#item-modal .viewer-left {
  flex: 7 1 0;
  position: relative;
  overflow: hidden;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  background:
    radial-gradient(ellipse 120% 80% at 50% 40%, rgba(133, 121, 96, 0.07) 0%, transparent 55%),
    linear-gradient(165deg, var(--vm-stage) 0%, var(--vm-stage-deep) 100%);
  cursor: grab;
  border-right: 1px solid var(--vm-line);
}
#item-modal .viewer-left:active {
  cursor: grabbing;
}
#item-modal #viewer-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  background: transparent;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#item-modal #viewer-stage-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#item-modal .viewer-main #viewer-video-local,
#viewer-stage #viewer-video-local {
  display: block;
  margin: 0 auto;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #000;
}
#item-modal .viewer-main iframe#viewer-video-remote:not(.viewer-embed-youtube),
#viewer-stage iframe#viewer-video-remote:not(.viewer-embed-youtube) {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  display: block;
}
/* YouTube: iframe height:auto 만으로는 높이가 무너짐 → 16:9 + 스테이지 높이 상한 */
#item-modal #viewer-stage-inner iframe.viewer-embed-youtube,
#viewer-stage iframe.viewer-embed-youtube {
  display: block !important;
  width: min(100%, 92vw) !important;
  max-width: 100% !important;
  height: auto !important;
  aspect-ratio: 16 / 9 !important;
  max-height: min(72dvh, calc(min(100vw, 92vw) * 9 / 16)) !important;
  margin: 0 auto !important;
  flex: 0 0 auto !important;
  border: 0;
  background: #000;
}
@media (max-width: 767.98px) {
  #item-modal #viewer-stage-inner iframe.viewer-embed-youtube,
  #viewer-stage iframe.viewer-embed-youtube {
    width: min(100%, 100vw) !important;
    max-height: min(38dvh, calc(min(100vw, 100vw) * 9 / 16)) !important;
  }
}
#item-modal #viewer-stage-inner #viewer-img,
#item-modal #viewer-stage-inner #pdf-frame {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  box-sizing: border-box;
}
#item-modal #viewer-stage-inner #viewer-img {
  object-fit: contain;
}
#item-modal #viewer-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  display: none;
  transform-origin: center center;
}
#item-modal .viewer-left img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
#item-modal #pdf-frame {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  border: none;
  background: #2a2a2a;
  display: none;
}
/* PC: 상단 「목록으로」는 모바일 전용(회색으로만 보이던 버튼 숨김) */
@media (min-width: 768px) {
  #item-modal .viewer-back-to-list {
    display: none !important;
  }
}
/* 동영상·PDF에서는 모바일에서도 목록으로 숨김 */
#item-modal.viewer-no-back-to-list .viewer-back-to-list {
  display: none !important;
}
/* PC: 확대·축소는 사진 영역이 아니라 헤더 닫기 왼쪽(이미지일 때만 JS로 표시) */
#item-modal .viewer-header-zoom {
  display: none;
  align-items: center;
  flex-shrink: 0;
  margin-right: 6px;
}
@media (min-width: 768px) {
  #item-modal .viewer-header-zoom {
    margin-right: 12px;
  }
}
#item-modal .viewer-header-zoom .viewer-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
#item-modal .viewer-header-zoom .viewer-controls button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  border: 1px solid var(--vm-line);
  border-radius: var(--vm-radius-sm);
  background: var(--vm-muted);
  color: var(--vm-text);
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
#item-modal .viewer-header-zoom .viewer-controls button:hover:not(:disabled) {
  border-color: var(--vm-point);
  color: var(--vm-point);
  background: var(--vm-point-soft);
  box-shadow: 0 0 0 1px var(--vm-point-soft);
}
#item-modal .viewer-header-zoom .viewer-controls button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
#item-modal #prev-btn,
#item-modal #next-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: transparent;
  border: 2px solid rgba(0, 175, 236, 0.7);
  color: rgba(255, 255, 255, 0.94);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  min-width: 44px;
  font-weight: 500;
  box-shadow: none;
  backdrop-filter: none;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}
#item-modal #prev-btn { left: 12px; }
#item-modal #next-btn { right: 12px; }
#item-modal #prev-btn:hover:not(:disabled),
#item-modal #next-btn:hover:not(:disabled) {
  border-color: var(--vm-point);
  color: #fff;
  background: rgba(0, 0, 0, 0.18);
}
#item-modal #prev-btn:disabled,
#item-modal #next-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.4);
}

#item-modal .viewer-right {
  flex: 2 1 0;
  min-width: 12.5rem;
  height: 100%;
  overflow-y: auto;
  padding: 20px 18px;
  background: #f0f2f5;
  border-left: 1px solid #e0e2e6;
  box-shadow: inset 6px 0 0 rgba(0, 175, 236, 0.06);
}
#item-modal #viewer-meta {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--vm-text);
}
#item-modal #viewer-meta h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--vm-ink);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--vm-point);
  letter-spacing: -0.02em;
}
#item-modal #viewer-meta .meta-row {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
#item-modal #viewer-meta .meta-row:last-child { border-bottom: none; }
#item-modal #viewer-meta strong { color: var(--vm-ink); font-weight: 600; }

#item-modal .thumbs-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  height: 100px;
  border-top: 1px solid var(--vm-line);
  background: linear-gradient(180deg, var(--vm-muted) 0%, var(--vm-surface) 100%);
}
#item-modal .thumb-prev,
#item-modal .thumb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  background: var(--vm-surface);
  color: var(--vm-text-muted);
  border: 1px solid var(--vm-line);
  width: 62px;
  height: 62px;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--vm-shadow);
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
#item-modal .thumb-prev { left: 10px; }
#item-modal .thumb-next { right: 10px; }
#item-modal .thumb-prev:hover,
#item-modal .thumb-next:hover {
  color: var(--vm-point);
  border-color: var(--vm-point);
  background: var(--vm-point-soft);
  box-shadow: 0 2px 12px rgba(0, 175, 236, 0.15);
}
#item-modal .viewer-thumbs {
  flex: 1;
  min-width: 0;
  display: flex;
  overflow-x: auto;
  gap: 12px;
  height: 100px;
  align-items: center;
  padding: 0 74px;
  background: var(--vm-surface);
  cursor: grab;
  user-select: none;
}
#item-modal .viewer-thumbs:active { cursor: grabbing; }
#item-modal .viewer-thumbs img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--vm-radius-sm);
  cursor: pointer;
  border: 2px solid var(--vm-line);
  flex-shrink: 0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#item-modal .viewer-thumbs img:hover {
  border-color: rgba(0, 175, 236, 0.45);
}
#item-modal .viewer-thumbs img.active {
  border: 2px solid var(--vm-point);
  box-shadow: 0 0 0 2px var(--vm-point-soft);
}
#item-modal .viewer-thumbs .thumb-pdf-poster {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--vm-radius-sm);
  cursor: pointer;
  border: 2px solid var(--vm-line);
  flex-shrink: 0;
  background: var(--vm-muted);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#item-modal .viewer-thumbs .thumb-pdf-poster:hover {
  border-color: rgba(0, 175, 236, 0.45);
}
#item-modal .viewer-thumbs .thumb-pdf-poster.active {
  border: 2px solid var(--vm-point);
  box-shadow: 0 0 0 2px var(--vm-point-soft);
}
#item-modal .viewer-thumbs .thumb-pdf {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--vm-muted);
  border: 2px solid var(--vm-line);
  border-radius: var(--vm-radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--vm-text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
#item-modal .viewer-thumbs .thumb-pdf:hover {
  border-color: rgba(0, 175, 236, 0.45);
  color: var(--vm-point);
}
#item-modal .viewer-thumbs .thumb-pdf.active {
  border: 2px solid var(--vm-point);
  color: var(--vm-point);
  background: var(--vm-point-soft);
  box-shadow: 0 0 0 2px var(--vm-point-soft);
}
#item-modal .viewer-thumbs .thumb-video {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--vm-radius-sm);
  cursor: pointer;
  border: 2px solid var(--vm-line);
  flex-shrink: 0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #1a1a1a;
  pointer-events: auto;
}
#item-modal .viewer-thumbs .thumb-video:hover {
  border-color: rgba(0, 175, 236, 0.45);
}
#item-modal .viewer-thumbs .thumb-video.active {
  border: 2px solid var(--vm-point);
  box-shadow: 0 0 0 2px var(--vm-point-soft);
}

/* ----- 모바일: 겹침 방지, 세로 스택(이미지 → 메타 → 썸), 뷰포트 안정 ----- */
@media (max-width: 767.98px) {
  #item-modal {
    align-items: stretch;
    justify-content: flex-end;
  }
  #item-modal .viewer-modal {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    border-radius: 0;
    overscroll-behavior: contain;
  }
  #item-modal .viewer-mo-topbar { display: none !important; }
  #item-modal .viewer-header-zoom {
    display: none !important;
  }
  #item-modal .viewer-back-to-list {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 auto 0 0;
    border: 1px solid #0f1216;
    background: #1e2329;
    color: #f8f9fa;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    padding: 0 14px;
    min-height: 44px;
    min-width: 90px;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  }
  #item-modal .viewer-back-to-list__ic { color: var(--vm-point); }
  #item-modal .viewer-back-to-list:active {
    background: #0f1216;
    border-color: var(--vm-point);
  }
  #item-modal .viewer-header {
    position: relative;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    justify-content: space-between;
  }
  #item-modal .viewer-header-right {
    position: static;
    z-index: 3;
    width: 100%;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
  }
  #item-modal #viewer-title {
    display: none !important;
  }
  #item-modal .viewer-header-tools { display: none !important; }
  #item-modal .item-nav {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
  #item-modal #viewer-maximize { display: none !important; }
  #item-modal #viewer-close.viewer-close-btn {
    width: auto;
    min-width: 78px;
    height: 44px;
    padding: 0 12px;
  }
  #item-modal #viewer-close .viewer-close__label {
    display: inline;
  }
  #item-modal #viewer-close.viewer-close-btn:hover {
    color: #fff;
    background: #0f1216;
    border-color: var(--vm-point);
  }
  #item-modal .viewer-body {
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }
  #item-modal .viewer-left {
    flex: 0 0 auto;
    width: 100%;
    min-height: min(40dvh, 300px);
    max-height: min(48dvh, 360px);
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--vm-line);
  }
  #item-modal .viewer-right {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    min-height: 0;
    max-height: min(32dvh, 280px);
    height: auto;
    border-left: 0;
    box-shadow: none;
    padding: 12px 14px 14px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  #item-modal #viewer-meta {
    font-size: 0.875rem;
  }
  #item-modal .thumbs-wrapper {
    height: 76px;
    flex-shrink: 0;
  }
  #item-modal.is-pdf-mobile .viewer-body {
    flex-direction: column;
  }
  #item-modal.is-pdf-mobile .viewer-left {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    height: auto;
    border-bottom: 1px solid var(--vm-line);
  }
  #item-modal.is-pdf-mobile .thumbs-wrapper {
    display: none !important;
  }
  #item-modal.is-pdf-mobile .viewer-right {
    display: block !important;
    flex: 0 0 clamp(120px, 22dvh, 200px);
    min-height: 110px;
    max-height: clamp(120px, 24dvh, 220px);
    width: 100%;
    min-width: 0;
    padding: 10px 12px 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  #item-modal.is-pdf-mobile #viewer-stage,
  #item-modal.is-pdf-mobile #viewer-stage-inner,
  #item-modal.is-pdf-mobile #pdf-frame {
    height: 100% !important;
    min-height: 0 !important;
  }
  #item-modal .viewer-thumbs {
    height: 76px;
    padding: 0 48px;
    gap: 8px;
  }
  #item-modal .thumb-prev,
  #item-modal .thumb-next {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }
  #item-modal .thumb-prev { left: 6px; }
  #item-modal .thumb-next { right: 6px; }
  #item-modal .viewer-thumbs img,
  #item-modal .viewer-thumbs .thumb-pdf-poster,
  #item-modal .viewer-thumbs .thumb-pdf,
  #item-modal .viewer-thumbs .thumb-video {
    width: 56px;
    height: 56px;
  }
  #item-modal #prev-btn,
  #item-modal #next-btn {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }
  #item-modal #prev-btn { left: 6px; }
  #item-modal #next-btn { right: 6px; }
}

.video-simple-modal {
  --vsm-surface: #ffffff;
  --vsm-muted: #f5f5f5;
  --vsm-line: #e1e1e1;
  --vsm-text: #2c2e35;
  --vsm-text-muted: #6b6e78;
  --vsm-point: #00afec;
  --vsm-point-soft: rgba(0, 175, 236, 0.14);
  --vsm-stage-bg: #1a1c22;
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100001;
  font-family: 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}
.video-simple-modal.active { display: flex; align-items: center; justify-content: center; }
.vsm-overlay {
  position: absolute;
  inset: 0;
  /* blur 금지: 비디오 디코딩·합성과 경쟁해 재생 렉 유발 */
  background: rgba(0, 0, 0, 0.82);
}
.vsm-container {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 88vw;
  height: 95vh;
  max-width: none;
  background: var(--vsm-surface);
  border-radius: 10px;
  border: 1px solid var(--vsm-line);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 1;
}
.vsm-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 12px 20px;
  background: linear-gradient(180deg, var(--vsm-surface) 0%, var(--vsm-muted) 100%);
  border-bottom: 1px solid var(--vsm-line);
  flex-shrink: 0;
}
.vsm-header-left { display: none !important; }
.vsm-nav {
  padding: 8px 16px;
  border: 1px solid var(--vsm-line);
  border-radius: 6px;
  background: var(--vsm-muted);
  color: var(--vsm-text);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.vsm-nav:hover:not(:disabled) {
  border-color: var(--vsm-point);
  color: var(--vsm-point);
  background: var(--vsm-point-soft);
}
.vsm-nav:disabled { opacity: 0.4; cursor: default; }
.vsm-title {
  display: none !important;
}
.vsm-header-right {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.vsm-back-to-list {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 2px solid var(--vsm-point);
  background: var(--vsm-point-soft);
  color: var(--vsm-text);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  cursor: pointer;
}
.vsm-back-to-list__ic {
  color: var(--vsm-point);
}
.vsm-back-to-list:active {
  background: rgba(0, 175, 236, 0.24);
}
/* PC: 동영상 심플 팝업도 이미지/PDF 메인 모달과 같이 닫기만(목록으로는 모바일 전용) */
@media (min-width: 768px) {
  .video-simple-modal .vsm-back-to-list {
    display: none !important;
  }
}
.vsm-header-right button {
  min-width: 90px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid #0f1216;
  background: #1e2329;
  color: #f8f9fa;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.vsm-header-right button:hover {
  border-color: var(--vsm-point);
  color: #fff;
  background: #0f1216;
}
.vsm-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}
.vsm-left {
  flex: 7 1 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 그라데이션 제거: 재생 중 페인트 부담 감소 */
  background: #12141a;
  border-right: 1px solid var(--vsm-line);
  min-height: 0;
  contain: layout style;
}
.vsm-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  box-sizing: border-box;
}
.vsm-video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #000;
  border-radius: 4px;
  transform: translateZ(0);
}
#video-simple-modal .vsm-video::-webkit-media-controls-overflow-button,
#video-simple-modal .vsm-video::-webkit-media-controls-download-button,
#video-simple-modal .vsm-video::-webkit-media-controls-picture-in-picture-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  -webkit-appearance: none !important;
}
.vsm-prev, .vsm-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 72px;
  border: none;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  font-size: 1.8rem;
  cursor: pointer;
  z-index: 10;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}
.vsm-prev { left: 16px; }
.vsm-next { right: 16px; }
.vsm-prev:hover, .vsm-next:hover { background: rgba(255,255,255,0.15); color: #fff; }
.vsm-prev:disabled, .vsm-next:disabled { opacity: 0.25; cursor: default; }
.vsm-right {
  flex: 3 1 0;
  display: flex;
  flex-direction: column;
  background: var(--vsm-surface);
  min-width: 240px;
  max-width: 320px;
  min-height: 0;
}
.vsm-right-top {
  flex: 3 1 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  min-height: 0;
  padding-top: 8px;
}
.vsm-right-reserve {
  flex: 1 1 auto;
  min-height: 16px;
}
.vsm-midline {
  flex: 0 0 auto;
  margin: 0;
  border: 0;
  border-top: 1px solid var(--vsm-line);
}
.vsm-right-bottom {
  flex: 6 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.vsm-info {
  flex-shrink: 0;
  padding: 0 20px 8px;
}
.vsm-info-row {
  display: flex;
  margin-bottom: 8px;
}
.vsm-info-row:last-child { margin-bottom: 0; }
.vsm-info-label {
  width: 60px;
  flex-shrink: 0;
  color: var(--vsm-text-muted);
  font-size: 0.85rem;
}
.vsm-info-value {
  flex: 1;
  color: var(--vsm-text);
  font-size: 0.85rem;
  word-break: break-all;
}
.vsm-list-header {
  flex-shrink: 0;
  padding: 12px 20px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--vsm-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.vsm-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 12px;
}
.vsm-list-item {
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--vsm-text);
  background: transparent;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vsm-list-item:hover { background: var(--vsm-muted); }
.vsm-list-item.active {
  background: var(--vsm-point-soft);
  color: var(--vsm-point);
  font-weight: 500;
}
.vsm-list-item .vsm-item-num {
  display: inline-block;
  width: 24px;
  color: var(--vsm-text-muted);
  font-size: 0.75rem;
}
.vsm-list-item.active .vsm-item-num { color: var(--vsm-point); }
@media (max-width: 900px) {
  .video-simple-modal.active {
    align-items: center;
    justify-content: center;
  }
  .vsm-container {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    border-radius: 0;
    box-sizing: border-box;
  }
  .vsm-header {
    flex-shrink: 0;
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top));
  }
  .vsm-header-right {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
  }
  .vsm-body {
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
  }
  .vsm-left {
    flex: 0 0 auto;
    min-height: 180px;
    max-height: min(58dvh, 460px);
    border-right: 0;
    border-bottom: 1px solid var(--vsm-line);
  }
  .vsm-stage {
    padding: 6px;
  }
  .vsm-right {
    display: flex !important;
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    min-height: 0;
  }
  .vsm-right-bottom {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .vsm-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: min(32dvh, 240px);
  }
}

