/**
 * Nhà Cỏ — Bộ sưu tập ảnh (10 layout)
 */
.col-hub {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 900px) {
  .col-hub { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .col-hub { grid-template-columns: 1fr 1fr; gap: .55rem; }
}

.col-admin {
  display: none;
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
/* Chỉ admin mới thấy khung chọn layout + upload */
body.admin-mode .col-admin {
  display: block;
  pointer-events: auto;
  opacity: 1;
}

.col-admin-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  margin-bottom: .85rem;
}
.col-admin-row:last-child { margin-bottom: 0; }
.col-admin label.col-upload {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 44px;
  padding: .65rem 1rem;
  background: var(--yellow);
  color: #fff;
  font-weight: 700;
  font-size: .8rem;
  cursor: pointer;
  border-radius: 4px;
}
.col-admin label.col-upload input { display: none; }

.col-layouts {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .5rem;
  width: 100%;
}
@media (max-width: 700px) {
  .col-layouts { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 420px) {
  .col-layouts { grid-template-columns: repeat(2, 1fr); }
}

.col-layout-btn {
  border: 2px solid var(--line);
  background: #fff;
  padding: .45rem;
  cursor: pointer;
  border-radius: 6px;
  text-align: center;
  font-size: .68rem;
  font-weight: 700;
  color: var(--soft);
}
.col-layout-btn.active,
.col-layout-btn:hover {
  border-color: var(--yellow);
  color: var(--ink);
}
.col-layout-preview {
  height: 36px;
  margin-bottom: .35rem;
  border-radius: 3px;
  background: var(--bg2);
  position: relative;
  overflow: hidden;
}
.col-layout-preview span {
  position: absolute;
  background: #c4b8a5;
  border-radius: 1px;
}

/* Mini previews for layout picker */
.lp-1 span { inset: 4px; height: 10px; width: auto; }
.lp-1 span:nth-child(2) { top: 16px; height: 14px; left: 4px; right: 40%; }
.lp-1 span:nth-child(3) { top: 16px; height: 14px; left: 62%; right: 4px; }
.lp-2 { display: grid !important; grid-template-columns: 1fr 1fr; gap: 2px; padding: 4px; background: transparent !important; }
.lp-2 span { position: static !important; height: 100%; }
.lp-3 { display: grid !important; grid-template-columns: 1fr 1fr 1fr; gap: 2px; padding: 4px; background: transparent !important; }
.lp-3 span { position: static !important; height: 100%; }
.lp-4 { display: grid !important; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 4px; background: transparent !important; }
.lp-4 span { position: static !important; height: 100%; }
.lp-5 span:first-child { left: 4px; top: 4px; right: 4px; height: 16px; }
.lp-5 span:nth-child(2) { left: 4px; bottom: 4px; width: 30%; height: 12px; }
.lp-5 span:nth-child(3) { left: 36%; bottom: 4px; width: 30%; height: 12px; }
.lp-5 span:nth-child(4) { right: 4px; bottom: 4px; width: 30%; height: 12px; }
.lp-6 span:nth-child(1) { left: 4px; top: 4px; width: 45%; height: 28px; }
.lp-6 span:nth-child(2) { right: 4px; top: 4px; width: 45%; height: 28px; }
.lp-7 span { width: 30%; height: 12px; }
.lp-7 span:nth-child(1) { left: 4px; top: 4px; height: 20px; }
.lp-7 span:nth-child(2) { left: 36%; top: 4px; height: 14px; }
.lp-7 span:nth-child(3) { right: 4px; top: 4px; height: 26px; }
.lp-8 { display: grid !important; grid-template-columns: 1fr 1fr 1fr; gap: 2px; padding: 4px; background: transparent !important; }
.lp-8 span { position: static !important; aspect-ratio: 1; height: auto; }
.lp-9 span { left: 4px; right: 4px; height: 8px; }
.lp-9 span:nth-child(1) { top: 4px; }
.lp-9 span:nth-child(2) { top: 14px; }
.lp-9 span:nth-child(3) { top: 24px; }
.lp-10 span:nth-child(1) { left: 4px; top: 4px; width: 55%; height: 22px; }
.lp-10 span:nth-child(2) { right: 4px; top: 4px; width: 35%; height: 12px; }
.lp-10 span:nth-child(3) { right: 4px; bottom: 4px; width: 35%; height: 12px; }
.lp-10 span:nth-child(4) { left: 4px; bottom: 4px; width: 55%; height: 8px; }

.col-gallery {
  margin-top: .5rem;
}
.col-gallery .col-item {
  position: relative;
  overflow: hidden;
  background: #111;
}
.col-gallery .col-item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: opacity .25s ease, transform .5s ease;
}
.col-gallery .col-item a {
  display: block;
  width: 100%;
  height: 100%;
}
.col-gallery .col-item:hover img { opacity: .92; }

.col-item .col-del {
  display: none;
  position: absolute;
  top: .4rem;
  right: .4rem;
  z-index: 5;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.78);
  color: #fff;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
body.admin-mode .col-item .col-del { display: inline-flex; align-items: center; justify-content: center; }
.col-item .col-del:hover { background: #c0392b; }

body.admin-mode .col-item {
  cursor: grab;
}
body.admin-mode .col-item.dragging {
  opacity: .45;
  outline: 2px dashed var(--yellow);
}

.col-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--soft);
  border: 1px dashed var(--line);
  background: var(--surface);
  border-radius: 10px;
}

/* ===== Layout 1: justified rows (filled by JS) ===== */
.col-gallery.layout-1 {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.col-gallery.layout-1 .col-row {
  display: flex;
  gap: .55rem;
  width: 100%;
}
.col-gallery.layout-1 .col-item {
  height: var(--row-h, 220px);
  flex: 0 0 auto;
}
.col-gallery.layout-1 .col-item img { object-fit: contain; background: #0a0a0a; }

/* ===== Layout 2–4: uniform grids ===== */
.col-gallery.layout-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
}
.col-gallery.layout-2 .col-item { aspect-ratio: 4 / 5; }

.col-gallery.layout-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
}
.col-gallery.layout-3 .col-item { aspect-ratio: 3 / 4; }
@media (max-width: 700px) {
  .col-gallery.layout-3 { grid-template-columns: repeat(2, 1fr); gap: .55rem; }
}

.col-gallery.layout-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .65rem;
}
.col-gallery.layout-4 .col-item { aspect-ratio: 3 / 4; }
@media (max-width: 900px) {
  .col-gallery.layout-4 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .col-gallery.layout-4 { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
}

/* ===== Layout 5: featured ===== */
.col-gallery.layout-5 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(120px, 18vw);
  gap: .65rem;
}
.col-gallery.layout-5 .col-item:first-child {
  grid-column: 1 / -1;
  grid-row: span 2;
  min-height: 280px;
}
@media (max-width: 700px) {
  .col-gallery.layout-5 {
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: minmax(100px, 28vw);
  }
  .col-gallery.layout-5 .col-item:first-child { min-height: 200px; }
}

/* ===== Layout 6: magazine ===== */
.col-gallery.layout-6 {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.col-gallery.layout-6 .col-item {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
  background: transparent;
  align-items: center;
}
.col-gallery.layout-6 .col-item:nth-child(even) {
  grid-template-columns: 0.9fr 1.1fr;
}
.col-gallery.layout-6 .col-item:nth-child(even) a { order: 2; }
.col-gallery.layout-6 .col-item a {
  aspect-ratio: 4 / 3;
  overflow: hidden;
}
.col-gallery.layout-6 .col-cap {
  font-family: var(--display);
  font-size: clamp(1.2rem, 2.5vw, 1.75rem);
  color: var(--ink);
  padding: .5rem;
}
@media (max-width: 700px) {
  .col-gallery.layout-6 .col-item,
  .col-gallery.layout-6 .col-item:nth-child(even) {
    grid-template-columns: 1fr;
  }
  .col-gallery.layout-6 .col-item:nth-child(even) a { order: 0; }
  .col-gallery.layout-6 .col-cap { display: none; }
}

/* ===== Layout 7: masonry columns ===== */
.col-gallery.layout-7 {
  column-count: 3;
  column-gap: .75rem;
}
.col-gallery.layout-7 .col-item {
  break-inside: avoid;
  margin-bottom: .75rem;
  display: inline-block;
  width: 100%;
}
.col-gallery.layout-7 .col-item img {
  height: auto;
  object-fit: contain;
}
@media (max-width: 800px) {
  .col-gallery.layout-7 { column-count: 2; }
}
@media (max-width: 480px) {
  .col-gallery.layout-7 { column-count: 2; gap: .45rem; }
}

/* ===== Layout 8: square ===== */
.col-gallery.layout-8 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .55rem;
}
.col-gallery.layout-8 .col-item { aspect-ratio: 1; }
@media (max-width: 600px) {
  .col-gallery.layout-8 { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Layout 9: cinematic ===== */
.col-gallery.layout-9 {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}
.col-gallery.layout-9 .col-item {
  aspect-ratio: 21 / 9;
  max-height: 52vh;
}
.col-gallery.layout-9 .col-item img { object-fit: cover; }
@media (max-width: 600px) {
  .col-gallery.layout-9 .col-item { aspect-ratio: 16 / 9; }
}

/* ===== Layout 10: collage ===== */
.col-gallery.layout-10 {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: minmax(90px, 12vw);
  gap: .55rem;
}
.col-gallery.layout-10 .col-item:nth-child(6n + 1) { grid-column: span 4; grid-row: span 2; }
.col-gallery.layout-10 .col-item:nth-child(6n + 2) { grid-column: span 2; grid-row: span 1; }
.col-gallery.layout-10 .col-item:nth-child(6n + 3) { grid-column: span 2; grid-row: span 1; }
.col-gallery.layout-10 .col-item:nth-child(6n + 4) { grid-column: span 2; grid-row: span 2; }
.col-gallery.layout-10 .col-item:nth-child(6n + 5) { grid-column: span 2; grid-row: span 1; }
.col-gallery.layout-10 .col-item:nth-child(6n + 6) { grid-column: span 2; grid-row: span 1; }
@media (max-width: 700px) {
  .col-gallery.layout-10 {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: minmax(110px, 28vw);
  }
  .col-gallery.layout-10 .col-item { grid-column: span 1 !important; grid-row: span 1 !important; }
  .col-gallery.layout-10 .col-item:nth-child(3n + 1) { grid-column: span 2 !important; grid-row: span 2 !important; }
}

.col-back {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 44px;
  background: none;
  border: none;
  color: var(--yellow-dark);
  font-weight: 700;
  font-size: .92rem;
  cursor: pointer;
  padding: 0;
  margin-bottom: .75rem;
}
.col-back:hover { color: var(--yellow); }

.col-meta {
  font-size: .85rem;
  color: var(--muted);
  margin-top: .35rem;
}
