#settingsModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  z-index: 50;
  overflow-y: auto;
}

#settingsModal[aria-hidden="false"] {
  display: block;
}

.modal-card {
  max-width: 780px;
  margin: 6vh auto;
  padding: 8px 0 12px;
  background: linear-gradient(
    180deg,
    rgba(17, 24, 39, 0.96),
    rgba(17, 24, 39, 0.92)
  );
  border: 1px solid #1f2937;
  border-radius: 16px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 640px) {
  .modal-card {
    max-width: calc(100% - 24px);
    margin: 3vh auto;
    border-radius: 12px;
  }

  .modal-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .modal-head > div {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .modal-head button {
    flex: 1;
  }
}

/* Background Gallery */
.bg-thumbnail {
  position: relative;
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.05);
}

.bg-thumbnail:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.bg-thumbnail.active {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.bg-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bg-thumbnail-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 10px;
  padding: 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bg-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.9);
  color: white;
  border: 2px solid white;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  padding: 0;
  font-weight: bold;
}

.bg-thumbnail:hover .bg-delete-btn {
  opacity: 1;
}

.bg-delete-btn:hover {
  background: rgba(185, 28, 28, 1);
  transform: scale(1.1);
}
