.mgd-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.mgd-filters__primary {
  flex: 1 1 auto;
  display: grid;
  gap: 0.75rem;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  justify-content: flex-start;
  align-items: end;
}

.mgd-search-field {
  display: flex;
  align-items: center;
  min-width: 216px;
}

.mgd-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid #b4b4b4;
  border-radius: 8px;
  background: #ffffff;
  width: fit-content;
  min-width: 216px;
  height: 45px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mgd-search:focus-within {
  border-color: var(--bde-brand-primary-color);
  box-shadow: 0 0 0 3px rgba(255, 130, 0, 0.15);
}

.mgd-search__icon {
  display: flex;
  align-items: center;
  color: #52606d;
}

.mgd-search__input {
  border: none;
  background: transparent;
  font-size: 0.95rem;
  line-height: 1.4;
  width: 100%;
  min-width: 140px;
}

.mgd-search__input:focus {
  outline: none;
}

.mgd-select-field {
  display: flex;
  align-items: center;
  min-width: 124px;
}

.mgd-select {
  position: relative;
  display: flex;
  align-items: center;
  padding: 7px 0;
  border: 1px solid #b4b4b4;
  border-radius: 8px;
  background: #ffffff;
  width: fit-content;
  min-width: 216px;
  height: 45px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.mgd-select:focus-within {
  border-color: var(--bde-brand-primary-color);
  box-shadow: 0 0 0 3px rgba(255, 130, 0, 0.15);
}

.mgd-select select {
  border: none;
  background: transparent;
  font-size: 0.95rem;
  line-height: 1.4;
  width: 100%;
  min-width: 140px;
  padding-right: calc(24px + 12px);
  padding-left: 12px;
  height: 100%;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
}

.mgd-select select:focus {
  outline: none;
}

.mgd-select::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 6px;
  background-repeat: no-repeat;
  background-size: 10px 6px;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237B8794' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  pointer-events: none;
}

.mgd-filters__sort {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: auto;
  cursor: pointer;
}

.mgd-sort-label {
  font-family: "Geist";
  font-size: 18px;
  font-weight: 500;
  color: #0c1f34;
}

.mgd-sort-select {
  padding: 10px;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  height: 45px;
  font-family: "Geist";
  font-size: 18px;
  font-weight: 500;
  line-height: 1.4;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237B8794' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 10px 6px;
  background-position: right 12px center;
  cursor: pointer;
}

.mgd-sort-select:focus {
  outline: none;
  border-color: transparent;
  box-shadow: unset;
}

.mgd-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .mgd-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .mgd-filters__primary {
    width: 100%;
    grid-auto-flow: row;
    grid-auto-columns: unset;
    grid-template-columns: 1fr 1fr;
  }

  .mgd-search-field,
  .mgd-select-field {
    min-width: 100%;
  }
  .mgd-search,
  .mgd-select {
    width: 100%;
  }

  .mgd-filters__sort {
    gap: 0.75rem;
    justify-content: flex-start;
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 600px) {
  .mgd-filters__primary {
    grid-template-columns: 1fr;
  }

  .mgd-search {
    width: 100%;
  }

  .mgd-select {
    width: 100%;
  }
}

.mgd-resource-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.mgd-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.mgd-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid #d2d6dc;
  border-radius: 999px;
  background: #f1f5f9;
  color: #52606d;
}

.mgd-error {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid #e57373;
  background: #fdecea;
  color: #c62828;
  border-radius: 0.375rem;
}

#resource_grid {
  position: relative;
}

#resource_grid.mgd-loading {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#resource_grid .mgd-category-group {
  margin-bottom: 3rem;
}

#resource_grid .mgd-category-title {
  margin: 0 0 1rem;
  font-family: "Geist";
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: #0f0f0f;
}

#resource_grid .mgd-category-group:last-of-type {
  margin-bottom: 0;
}

#resource_grid .mgd-category-group .mgd-loop {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (max-width: 900px) {
  #resource_grid .mgd-category-group .mgd-loop {
    grid-template-columns: 1fr;
  }
}

#resource_grid .mgd-loop-item {
  margin: 0;
  list-style: none;
}

#resource_grid .mgd-empty {
  font-size: 1rem;
  color: #52606d;
  text-align: center;
  padding: 2rem 1rem;
  width: 100%;
}

.mgd-related-resources {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.mgd-related-track {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .mgd-related-track {
    grid-template-columns: 1fr;
  }
}

.mgd-related-item {
  display: none;
}

.mgd-related-item.is-active {
  display: block;
}

.mgd-related-dots {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
}

.mgd-related-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
  border: none;
  background: #d1d5db;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.mgd-related-dot.is-active {
  background: #2680c2;
  transform: scale(1.1);
}

.mgd-related-dot:focus-visible {
  outline: 2px solid #2680c2;
  outline-offset: 2px;
}

.mgd-related-fallback {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  border: 1px solid #e4e7eb;
  border-radius: 0.75rem;
  background: #ffffff;
  height: 100%;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

.mgd-related-fallback img {
  width: 100%;
  border-radius: 0.5rem;
  object-fit: cover;
}

.mgd-related-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.4;
}

.mgd-related-title a {
  color: #0f0f0f;
  text-decoration: none;
}

.mgd-related-title a:hover {
  color: #2680c2;
}

.mgd-related-excerpt {
  margin: 0 0 0.5rem;
  color: #52606d;
  font-size: 0.95rem;
  line-height: 1.6;
}

.mgd-lightbox-open {
  overflow: hidden;
}

.mgd-lightbox {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.mgd-lightbox.is-active {
  display: flex;
}

.mgd-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
}

.mgd-lightbox__dialog {
  position: relative;
  width: min(90vw, 960px);
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 25px 45px rgba(15, 23, 42, 0.35);
  z-index: 1;
}

.mgd-lightbox__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.mgd-lightbox__close:hover,
.mgd-lightbox__close:focus-visible {
  background: rgba(255, 255, 255, 0.4);
}

.mgd-lightbox__iframe {
  width: 100%;
  height: 100%;
}

.mgd-audio-open {
  overflow: hidden;
}

.mgd-audio-lightbox {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.mgd-audio-lightbox.is-active {
  display: flex;
}

.mgd-audio-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
}

.mgd-audio-lightbox__dialog {
  position: relative;
  width: min(90vw, 480px);
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem 1.5rem;
  box-shadow: 0 25px 45px rgba(15, 23, 42, 0.25);
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mgd-audio-lightbox__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.1);
  color: #1f2933;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.mgd-audio-lightbox__close:hover,
.mgd-audio-lightbox__close:focus-visible {
  background: rgba(15, 23, 42, 0.25);
}

.mgd-audio-lightbox__title {
  margin: 0;
  padding-right: 2.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: #1f2933;
}

.mgd-audio-lightbox__audio {
  width: 100%;
}
#resource_grid > .mgd-loop {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
  margin: 0;
  padding: 0;
  list-style: none;
}
