.admin-page-gallery .content-stack,
.public-content-gallery {
  gap: 14px;
}

.im-gallery {
  --ig-ink: #142119;
  --ig-muted: #6f7d75;
  --ig-line: #d4ded8;
  --ig-green: #087f5b;
  --ig-lime: #c9ff3d;
  --ig-panel: #fff;
  min-width: 0;
  color: var(--ig-ink);
}

.im-gallery svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.im-gallery-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  border: 1px solid var(--ig-line);
  border-top: 4px solid var(--ig-ink);
  background: var(--ig-panel);
}

.im-gallery-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--ig-green);
  font: 500 10px/1.2 "DM Mono", monospace;
  text-transform: uppercase;
}

.im-gallery-intro h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: 0;
}

.im-gallery-intro p {
  margin: 7px 0 0;
  color: var(--ig-muted);
  font-size: 13px;
}

.im-gallery-total {
  display: grid;
  min-width: 92px;
  padding: 4px 20px;
  border-left: 1px solid var(--ig-line);
}

.im-gallery-total strong {
  font-size: 25px;
  line-height: 1;
}

.im-gallery-total span {
  margin-top: 5px;
  color: var(--ig-muted);
  font: 500 9px/1 "DM Mono", monospace;
  text-transform: uppercase;
}

.im-gallery-add {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border: 1px solid var(--ig-ink);
  border-radius: 6px;
  background: var(--ig-ink);
  color: #fff;
  text-decoration: none;
}

.im-gallery-add svg { color: var(--ig-lime); }
.im-gallery-add span { display: grid; gap: 2px; }
.im-gallery-add strong { font-size: 12px; }
.im-gallery-add small { color: #9eada5; font-size: 9px; }

.im-gallery-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 130px 170px auto auto auto;
  align-items: end;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--ig-line);
  background: #fff;
}

.im-gallery-toolbar label {
  display: grid;
  gap: 4px;
  color: var(--ig-muted);
  font: 500 9px/1.2 "DM Mono", monospace;
  text-transform: uppercase;
}

.im-gallery-toolbar input,
.im-gallery-toolbar select,
.im-gallery-filter-button,
.im-gallery-clear {
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  border: 1px solid #ccd8d1;
  border-radius: 5px;
  background: #f8faf9;
  color: var(--ig-ink);
  font: 600 12px/1 Manrope, sans-serif;
}

.im-gallery-search {
  position: relative;
  align-self: end;
}

.im-gallery-search svg {
  position: absolute;
  top: 11px;
  left: 12px;
  z-index: 1;
  width: 17px;
  height: 17px;
  color: #718078;
}

.im-gallery-search input { padding-left: 38px; }

.im-gallery-favorite-filter {
  display: flex !important;
  min-height: 40px;
  align-items: center;
  grid-auto-flow: column;
  justify-content: center;
  gap: 7px !important;
  padding: 0 12px;
  border: 1px solid #ccd8d1;
  border-radius: 5px;
  background: #f8faf9;
  cursor: pointer;
  white-space: nowrap;
}

.im-gallery-favorite-filter input {
  position: absolute;
  width: 1px;
  min-height: 1px;
  opacity: 0;
}

.im-gallery-favorite-filter:has(input:checked) {
  border-color: #d4a72c;
  background: #fff9db;
  color: #8a5b00;
}

.im-gallery-favorite-filter svg { width: 15px; height: 15px; }

.im-gallery-filter-button,
.im-gallery-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.im-gallery-filter-button {
  border-color: var(--ig-ink);
  background: var(--ig-ink);
  color: #fff;
}

.im-gallery-filter-button svg { width: 15px; height: 15px; }

.im-gallery-selection {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 6px 10px;
  border: 1px solid var(--ig-line);
  background: #eef4f0;
}

.im-gallery-selection > span {
  margin-right: auto;
  color: var(--ig-muted);
  font-size: 11px;
}

.im-gallery-selection button {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid #c9d5ce;
  border-radius: 5px;
  background: #fff;
  color: var(--ig-ink);
  font: 700 11px/1 Manrope, sans-serif;
  cursor: pointer;
}

.im-gallery-selection button svg { width: 14px; height: 14px; }
.im-gallery-selection button.is-danger { border-color: #d9505b; background: #d9505b; color: #fff; }
.im-gallery-selection button:disabled { opacity: .38; cursor: not-allowed; }

.im-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 10px;
  margin-top: 12px;
}

.im-gallery-photo {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--ig-line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(20, 33, 25, .05);
}

.im-gallery-photo.is-selected {
  border-color: var(--ig-green);
  box-shadow: 0 0 0 2px rgba(8, 127, 91, .18);
}

.im-gallery-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(145deg, #22362c, #0d1b14);
}

.im-gallery-media.is-missing::before {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255,255,255,.55);
  content: "IRONMAGAROLA";
  font: 500 10px/1 "DM Mono", monospace;
}

.im-gallery-open {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.im-gallery-open::after {
  position: absolute;
  inset: 30% 0 0;
  background: linear-gradient(transparent, rgba(6, 14, 10, .82));
  content: "";
}

.im-gallery-open img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .28s ease, filter .28s ease;
}

.im-gallery-photo:hover .im-gallery-open img { transform: scale(1.025); }

.im-gallery-expand {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 50%;
  background: rgba(8,18,12,.48);
  color: #fff;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity .18s ease, transform .18s ease;
}

.im-gallery-expand svg { width: 14px; height: 14px; }
.im-gallery-photo:hover .im-gallery-expand { opacity: 1; transform: translateY(0); }

.im-gallery-caption {
  position: absolute;
  right: 14px;
  bottom: 13px;
  left: 14px;
  z-index: 2;
  display: grid;
  gap: 4px;
  pointer-events: none;
}

.im-gallery-caption time {
  color: var(--ig-lime);
  font: 500 9px/1.2 "DM Mono", monospace;
  text-transform: uppercase;
}

.im-gallery-caption strong {
  overflow: hidden;
  color: #fff;
  font-size: 14px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.im-gallery-select {
  position: absolute;
  top: 11px;
  left: 11px;
  z-index: 4;
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.52);
  border-radius: 50%;
  background: rgba(8,18,12,.52);
  cursor: pointer;
}

.im-gallery-select input { position: absolute; opacity: 0; }
.im-gallery-select span { width: 13px; height: 13px; border: 1.5px solid #fff; border-radius: 3px; }
.im-gallery-select input:checked + span { border-color: var(--ig-lime); background: var(--ig-lime); box-shadow: inset 0 0 0 3px rgba(8,18,12,.82); }

.im-gallery-favorite {
  position: absolute;
  top: 11px;
  right: 11px;
  z-index: 4;
  margin: 0;
}

.im-gallery-favorite button,
.im-gallery-favorite.is-static {
  display: grid;
  width: 31px;
  height: 31px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255,255,255,.52);
  border-radius: 50%;
  background: rgba(8,18,12,.52);
  color: #fff;
}

.im-gallery-favorite button { cursor: pointer; }
.im-gallery-favorite svg { width: 15px; height: 15px; }
.im-gallery-photo.is-favorite .im-gallery-favorite button,
.im-gallery-favorite.is-static { color: #ffd34d; }
.im-gallery-photo.is-favorite .im-gallery-favorite svg,
.im-gallery-favorite.is-static svg { fill: currentColor; }

.im-gallery-photo-footer {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 10px;
  border-top: 1px solid var(--ig-line);
  background: #fff;
}

.im-gallery-links {
  display: flex;
  min-width: 0;
  flex: 1;
  gap: 5px;
  overflow: hidden;
}

.im-gallery-links a,
.im-gallery-links span {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: #456258;
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.im-gallery-links a:hover { color: var(--ig-green); }
.im-gallery-photo-footer form { margin: 0; flex: 0 0 auto; }
.im-gallery-photo-footer button {
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 1px solid #d7e0db;
  border-radius: 5px;
  background: #fff;
  color: #78857e;
  cursor: pointer;
}
.im-gallery-photo-footer button:hover { border-color: #e6a6ad; color: #b52f3c; }
.im-gallery-photo-footer svg { width: 14px; height: 14px; }

.im-gallery-dialog {
  width: min(1180px, 94vw);
  max-width: none;
  max-height: 92vh;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: #08120d;
  color: #fff;
  box-shadow: 0 30px 90px rgba(0,0,0,.55);
}

.im-gallery-dialog::backdrop { background: rgba(5,12,8,.88); backdrop-filter: blur(5px); }
.im-gallery-dialog > img { display: block; width: 100%; max-height: 82vh; object-fit: contain; background: #08120d; }
.im-gallery-dialog > div { display: flex; align-items: center; gap: 14px; padding: 12px 16px; }
.im-gallery-dialog time { color: var(--ig-lime); font: 500 9px/1.2 "DM Mono", monospace; }
.im-gallery-dialog strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.im-gallery-dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255,255,255,.48);
  border-radius: 50%;
  background: rgba(8,18,12,.7);
  color: #fff;
  cursor: pointer;
}

.im-gallery-empty {
  display: grid;
  min-height: 280px;
  place-items: center;
  align-content: center;
  gap: 7px;
  margin-top: 12px;
  border: 1px dashed #bfcfc6;
  background: #f7faf8;
  text-align: center;
}
.im-gallery-empty p { margin: 0; color: var(--ig-muted); }
.im-gallery-empty a { color: var(--ig-green); font-weight: 800; }

/* Public gallery: immersive and free of management chrome. */
.im-gallery.is-public .im-gallery-intro {
  min-height: 168px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 30px 34px;
  border-color: rgba(255,255,255,.12);
  background: #11251b;
  color: #fff;
}
.im-gallery.is-public .im-gallery-eyebrow { color: var(--ig-lime); }
.im-gallery.is-public .im-gallery-intro h1 { max-width: 760px; font-size: 42px; }
.im-gallery.is-public .im-gallery-intro p { color: #afbeb6; }
.im-gallery.is-public .im-gallery-total { border-color: rgba(255,255,255,.18); }
.im-gallery.is-public .im-gallery-total span { color: #9eaea6; }
.im-gallery.is-public .im-gallery-toolbar { margin-top: 10px; }
.im-gallery.is-public .im-gallery-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); gap: 12px; }
.im-gallery.is-public .im-gallery-media { aspect-ratio: 16 / 11; }
.im-gallery.is-public .im-gallery-photo { border: 0; box-shadow: 0 8px 24px rgba(20,33,25,.09); }
.im-gallery.is-public .im-gallery-caption strong { font-size: 16px; }

@media (min-width: 1700px) {
  .im-gallery-grid { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
  .im-gallery.is-public .im-gallery-grid { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
}

@media (max-width: 1250px) {
  .im-gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .im-gallery-toolbar { grid-template-columns: minmax(200px, 1fr) repeat(2, 140px) auto auto; }
  .im-gallery-clear { grid-column: 1 / -1; width: max-content; min-height: 28px; border: 0; background: transparent; }
}

@media (max-width: 900px) {
  .im-gallery-intro { grid-template-columns: minmax(0,1fr) auto; }
  .im-gallery-add { grid-column: 1 / -1; width: max-content; }
  .im-gallery-toolbar { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .im-gallery-search { grid-column: 1 / -1; }
  .im-gallery-grid,
  .im-gallery.is-public .im-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 580px) {
  .im-gallery-intro,
  .im-gallery.is-public .im-gallery-intro { grid-template-columns: minmax(0,1fr) auto; min-height: 0; padding: 18px; }
  .im-gallery-intro h1,
  .im-gallery.is-public .im-gallery-intro h1 { font-size: 25px; }
  .im-gallery-intro p { font-size: 12px; }
  .im-gallery-total { min-width: 58px; padding: 3px 0 3px 14px; }
  .im-gallery-total strong { font-size: 21px; }
  .im-gallery-add { grid-column: 1 / -1; width: 100%; box-sizing: border-box; }
  .im-gallery-toolbar { grid-template-columns: 1fr; }
  .im-gallery-search { grid-column: auto; }
  .im-gallery-selection { display: grid; grid-template-columns: 1fr auto; }
  .im-gallery-selection > span { margin: 0; }
  .im-gallery-selection .is-danger { grid-column: 1 / -1; justify-content: center; }
  .im-gallery-grid,
  .im-gallery.is-public .im-gallery-grid { grid-template-columns: 1fr; gap: 9px; }
  .im-gallery-media,
  .im-gallery.is-public .im-gallery-media { aspect-ratio: 4 / 3; }
  .im-gallery-expand { display: none; }
}
