/* Shared CMS image gallery + editor boxes. Public + TinyMCE content_css + Cẩm nang. */
.ct-editor-gallery{
  display:grid;
  grid-template-columns:minmax(0,1fr);
  gap:10px;
  margin:12px 0 16px;
  max-width:100%;
  align-items:stretch;
}
.ct-editor-gallery > figure{
  margin:0;
  min-width:0;
  overflow:hidden;
  border-radius:14px;
  background:#edf3ef;
}
.ct-editor-gallery img{
  width:100%;
  display:block;
  margin:0;
  border-radius:0;
}
.ct-editor-gallery figcaption,
.ct166-itin-caption{
  display:block;
  margin:8px 0 0;
  font-size:13px;
  line-height:1.45;
  color:#66776d;
  font-weight:500;
}

/* 1 ảnh: rộng theo nội dung, giữ tỉ lệ gốc, không ép khung crop */
.ct-editor-gallery-1,
.ct-editor-gallery:has(> :nth-child(1):last-child){
  grid-template-columns:minmax(0,1fr);
}
.ct-editor-gallery-1 > figure,
.ct-editor-gallery:has(> :nth-child(1):last-child) > figure{
  aspect-ratio:auto;
  max-height:none;
  height:auto;
  background:transparent;
}
.ct-editor-gallery-1 img,
.ct-editor-gallery:has(> :nth-child(1):last-child) img{
  height:auto;
  max-height:none;
  object-fit:contain;
  object-position:center;
}

/* 2 ảnh: 2 cột đều, cùng chiều cao, crop nhẹ 4:3 */
.ct-editor-gallery-2,
.ct-editor-gallery:has(> :nth-child(2):last-child){
  grid-template-columns:repeat(2,minmax(0,1fr));
}
.ct-editor-gallery-2 > figure,
.ct-editor-gallery:has(> :nth-child(2):last-child) > figure{
  aspect-ratio:4/3;
}
.ct-editor-gallery-2 img,
.ct-editor-gallery:has(> :nth-child(2):last-child) img{
  height:100%;
  object-fit:cover;
  object-position:center;
}

/* 3 ảnh: 1 hàng, 3 ô bằng nhau */
.ct-editor-gallery-3,
.ct-editor-gallery:has(> :nth-child(3):last-child){
  grid-template-columns:repeat(3,minmax(0,1fr));
}
.ct-editor-gallery-3 > figure,
.ct-editor-gallery:has(> :nth-child(3):last-child) > figure{
  aspect-ratio:4/3;
}
.ct-editor-gallery-3 img,
.ct-editor-gallery:has(> :nth-child(3):last-child) img{
  height:100%;
  object-fit:cover;
  object-position:center;
}

/* 4 ảnh: 2x2. 5+ : 3 cột desktop */
.ct-editor-gallery-4,
.ct-editor-gallery:has(> :nth-child(4)){
  grid-template-columns:repeat(2,minmax(0,1fr));
}
.ct-editor-gallery:has(> :nth-child(5)){
  grid-template-columns:repeat(3,minmax(0,1fr));
}
.ct-editor-gallery-4 > figure,
.ct-editor-gallery:has(> :nth-child(4)) > figure{
  aspect-ratio:4/3;
}
.ct-editor-gallery-4 img,
.ct-editor-gallery:has(> :nth-child(4)) img{
  height:100%;
  object-fit:cover;
  object-position:center;
}

.ct-editor-box,
.ct166-itin-menu,
.ct166-itin-note,
.ct166-itin-hl{
  margin:12px 0 16px;
  padding:14px 16px;
  border-radius:14px;
  color:#173229;
}
.ct-editor-box-menu,
.ct166-itin-menu{
  background:#fffaf4;
  border:1px solid #f0dcc6;
}
.ct-editor-box-note,
.ct166-itin-note{
  background:#f4faf6;
  border:1px solid #d5e7db;
  border-left:4px solid #0b7d49;
  padding-left:14px;
}
.ct-editor-box-hl,
.ct166-itin-hl{
  background:#f7fbf8;
  border:1px solid #d5e7db;
}
.ct166-itin-menu p,
.ct166-itin-note p,
.ct-editor-box p{margin:0 0 8px}
.ct166-itin-menu p:last-child,
.ct166-itin-note p:last-child,
.ct-editor-box p:last-child{margin-bottom:0}
.ct166-itin-menu ol,
.ct166-itin-menu ul{margin:8px 0 0;padding-left:1.2em}
.ct166-itin-menu li{margin:0 0 4px;line-height:1.5}

@media(max-width:768px){
  .ct-editor-gallery{gap:8px}
  .ct-editor-gallery:has(> :nth-child(5)){grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:640px){
  .ct-editor-gallery,
  .ct-editor-gallery-1,
  .ct-editor-gallery-2,
  .ct-editor-gallery-3,
  .ct-editor-gallery-4,
  .ct-editor-gallery:has(> :nth-child(2):last-child),
  .ct-editor-gallery:has(> :nth-child(3):last-child),
  .ct-editor-gallery:has(> :nth-child(4)),
  .ct-editor-gallery:has(> :nth-child(5)){
    grid-template-columns:minmax(0,1fr);
    gap:8px;
  }
  .ct-editor-gallery > figure{
    aspect-ratio:auto !important;
    height:auto;
    max-height:none;
    background:transparent;
  }
  .ct-editor-gallery img{
    height:auto !important;
    object-fit:contain;
    width:100%;
  }
}
